/**
 * 
 */
package com.tjtt.tdm.codeReview.action;


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.google.gson.JsonObject;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.config.providers.XmlHelper;
import com.sun.org.apache.xml.internal.security.signature.Manifest;
import com.tjtt.common.utils.DateUtilsAll;
import com.tjtt.common.utils.TotalFlowXmlTool;
import com.tjtt.gwm.bean.Junyans;
import com.tjtt.gwm.service.EquipmentService;
import com.tjtt.gwm.service.WeituodanService;
import com.tjtt.tdm.base.BaseAction;
import com.tjtt.tdm.base.PageResult;
import com.tjtt.tdm.base.PubMethod;
import com.tjtt.tdm.base.StringUtil;
import com.tjtt.tdm.codeReview.service.ICodeReviewService;
import com.tjtt.tdm.flow.bean.FlowDetailed;
import com.tjtt.tdm.flow.bean.FlowTask;
import com.tjtt.tdm.flow.bean.FlowTaskInfo;
import com.tjtt.tdm.flow.bean.Flowstate;
import com.tjtt.tdm.flow.bean.Flowtype;
import com.tjtt.tdm.flow.bean.StepEntity;
import com.tjtt.tdm.form.bean.AutoFormsField;
import com.tjtt.tdm.form.bean.AutoFormsNew;
import com.tjtt.tdm.form.bean.TdmAnnex;
import com.tjtt.tdm.form.service.IAutoFormService;
import com.tjtt.tdm.form.service.IAutoService;
import com.tjtt.tdm.system.bean.Users;
import com.tjtt.tdm.system.service.ConfigService;
import com.tjtt.tdm.system.service.LogService;
import com.tjtt.tdm.util.ExcelTool;
import com.tjtt.tdm.util.ImageHelper;
import com.tjtt.tdm.util.WordTool;

/**
 * 
 * @author 张海娜
 *
 */
public class CodeReviewActionNew extends BaseAction{
    
	private static final long serialVersionUID = -8282568955946054881L;
	private LogService logService;
	private ICodeReviewService codeReviewService;
	private IAutoService autoService;
	private IAutoFormService autoFormService;
	private EquipmentService epService; 
	
	private Flowtype flowtype;
	private Users user;
	private String isshow = "10";
	public static final int MOD_CHECK = 3;
	
	private List uploadfile;
	private List uploadfileContentType;
	private List uploadfileFileName;
	
	
	public String initCodeReviewAddOne()  throws IOException{
		String flowid = this.getRequest().getParameter("flowid").trim();
		String mainid = this.getRequest().getParameter("mainid");
		flowtype = codeReviewService.findFileNameById(Long.parseLong(flowid));
		String filename = flowtype.getFilename();
		String path = PubMethod.GetFlowFilePath()+filename;
		TotalFlowXmlTool fxs = new TotalFlowXmlTool(path);
		List<Flowstate> formidlist = fxs.GetFormlists();
		//流程挂的表单的id
//		String formid = formidlist.get(0).getForm();
		String formid = this.getRequest().getParameter("formid");
		AutoFormsNew formnew =  autoFormService.getAutoFormsNewById(formid);
		Flowstate fs = fxs.GetFlowBeginState();
		String stateid = fs.getStateid();
		List<StepEntity> steps = fxs.GetListByText(stateid);
		String columns = "";
		StringBuffer sb = new StringBuffer();
		String columnHidden = "";
		Long waijianValue = 0l;
		String tablejs = "";
		int k = 0;
		String entityTableId = getID();
		sb.append("<div id='tt' class='easyui-tabs' style='width:"+formnew.getFormwidth()+"px'>");
		sb.append("<input type='hidden' name='mainid' id='mainid' value='"+mainid+"'/>");
		if(PubMethod.GetFlowid("flow.templetFlowId").equals(flowid)){
			sb.append("<input type='hidden' name='shenheren' id='shenheren' value=''/>");
		}
		//查询flow_task的Id
		String flowtaskId = "";
		String cxxlSql = " select SEQ_FLOW_TASK.nextval from dual "; 
		List listSeq = autoService.getDatabySql(cxxlSql);
		if(listSeq != null && listSeq.size() != 0){
			flowtaskId = listSeq.get(0).toString();
		}
		try {
				Flowstate flowstate = formidlist.get(k);
				//查询表单信息
				AutoFormsNew formnew1 =  autoFormService.getAutoFormsNewById(formid);
				//查询字段信息
				List<AutoFormsField> fieldList = autoFormService.getAutoFormsFieldByformid(formid);
				
				
				if(fieldList.size()>0){
			
						String formColumn = String.valueOf(formnew1.getFormColumn());
						sb.append("<div title='"+formnew1.getFormCnName()+"' style='padding:20px;'>\r\n");
						sb.append("<table width='100%' border='0' align='center' class='formTableNew'>\r\n");
						
						if("1".equals(formColumn) || formnew1.getFormColumn()==null){//如果是一列显示
							if (steps!=null)
							{
								sb.append("<tr><td style='text-align:right;width:120px;'>流程名称：</td><td colspan='3'><input type='text' id='flowname' name='flowname' value='"+flowtype.getFlowname()+"' style='border: 1px solid #999;padding: 5px;width:705px'></td>");
							}
							for(AutoFormsField field : fieldList){
								if(!field.getFieldName().equals("ID")){//除了ID的添加
									//是否页面显示
									if("0".equals(field.getIsPageShow().toString())){
										//columnHidden += "<input type='hidden' id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\"/>";
										continue;
									}
									columns += field.getFieldName() + ",";
									sb.append("<tr>");
									sb.append("<td align=\"right\">"+field.getCnName()+"：</td>");
									sb.append("<td align=\"left\">");
									sb.append(getAddHtml(field,entityTableId));
									sb.append("</td>");
									sb.append("</tr>");
									
								}
							}
							//列表展示
							String columnName = formnew1.getColumnCnName();
							String columnSql = formnew1.getColumnSql();
							String specialColumn = formnew1.getSpecialColumn();  //显示信息 1：样品/检测项目 2：人员分配 3：原始记录分配 4：报告分配
							Long specialType = formnew1.getSpecialType();   //操作类型  1：编辑  2：查看
							
							if(!StringUtil.isEmpty(columnName) && !StringUtil.isEmpty(columnSql)){
								String tablenum = String.valueOf(k);
								tablejs += FormHandler.getTableJS(String.valueOf(formnew1.getId()),tablenum, columnName,columnSql,formnew1.getColumnWidth(),"",false);
								getRequest().setAttribute("tablejs", tablejs);
								sb.append("<tr>");
								sb.append("<td colspan='2' align='center'>"); 
								sb.append("<table style=\"width: 90%;\" class=\"tableCont\">"); 
								sb.append("<tr>");
								sb.append("<td>"); 
								sb.append("<table id=\"gridTable"+tablenum+"\"></table>");
								sb.append("<div id=\"gridPager"+tablenum+"\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
							}
							else if(!StringUtil.isEmpty(specialColumn)){
								//样品列表
								tablejs += FormHandler.getSampleTable(flowtaskId);
								//检测项目列表
								tablejs += FormHandler.getItemeTable(flowtaskId,"0",String.valueOf(specialType));
								//其他检测项目列表
								//tablejs += FormHandler.getItemeTable2(flowtaskId);
								
							    getRequest().setAttribute("tablejs", tablejs);
								//样品/检测项目 多tab页
								if("1".equals(specialColumn)){
									sb.append("<tr>");
									sb.append("<td colspan='4' align='center'>"); 
									sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
									sb.append("<div title='样       品' style='padding:10px'>");
									sb.append("<input id='saveBtn1' type='button'  value='添 加' onclick=\"addSampleGrid()\" class='form_bt_orange'/>\r\n");
									sb.append("<input id='updateBtn1' type='button'  value='修 改'  onclick=\"updateSampleGrid()\" class='form_bt_orange'/>\r\n");
									sb.append("<input id='deleteBtn1' type='button'  value='删 除' onclick=\"deleteSampleGrid()\" class='form_bt_orange'/>\r\n");
									sb.append("<input id='deleteBtn1' type='button'  value='下载模版' onclick=\"downloadSampleModel()\" class='form_bt_orange'/>\r\n");
									sb.append("<input id='deleteBtn1' type='button'  value='模版导入' onclick=\"SampleModeImport()\" class='form_bt_orange'/>\r\n");
									sb.append("<table id=\"gridTableSample\"></table>");
									sb.append("<div id=\"gridPagerSample\"></div>");
									sb.append("</div>");
									sb.append("<div title='检测项目' style='padding:10px'>");
									sb.append("<input id='selectBtn2' type='button'  value='选择项目' onclick=\"selectItemGrid()\" class='form_bt_orange'/> &nbsp;\r\n");
									sb.append("<input id='deleteBtn2' type='button'  value='删 除' onclick=\"deleteItemGrid()\"  class='form_bt_orange'/> &nbsp;\r\n");
									sb.append("<input id='saveBtn2' type='button'  value='保存列表' onclick=\"saveItemGrid(0)\"  class='form_bt_orange'/> &nbsp;\r\n");
							//		sb.append("<input id='saveBtn2' type='button'  value='上传附件' onclick=\"itemGrid1UploadFile('gridTableItem1','0')\" class='form_bt_orange'/> &nbsp;\r\n");
									sb.append("<table id=\"gridTableItem1\"></table>");
									sb.append("<div id=\"gridPagerItem1\"></div>");
									sb.append("</div>");
//									sb.append("<div title='其他检测项目' style='padding:10px'>");
//									sb.append("<input id='addBtn3' type='button'  value='添 加' onclick=\"addRowtoItem2()\" class='form_bt_orange'/>&nbsp;\r\n");
//									sb.append("<input id='deleteBtn3' type='button'  value='删 除' onclick=\"deleteGridItem3()\" class='form_bt_orange'/> &nbsp;\r\n");
//									sb.append("<input id='saveBtn3' type='button'  value='保存列表'  onclick=\"saveGridOtherItem(0)\" class='form_bt_orange'/> &nbsp;\r\n");
//									sb.append("<input id='saveBtn3' type='button'  value='存入数据库' onclick=\"saveDataIntoItem()\" class='form_bt_orange'/> &nbsp;\r\n");
//							//		sb.append("<input id='saveBtn2' type='button'  value='上传附件' onclick=\"itemGrid1UploadFile('gridTableItem2','0')\" class='form_bt_orange'/> &nbsp;\r\n");
//									sb.append("<table id=\"gridTableItem2\"></table>");
//									sb.append("<div id=\"gridPagerItem2\"></div>");
//									sb.append("</div>");
								    sb.append("</td>");
									sb.append("</tr>");
								}
							}
							if (steps!=null)
							{
								String isshow = "";
								if (steps.size()<=1)
								{
									isshow = "none";
								}
								sb.append("<tr style='display:"+isshow+";'><td style='text-align:right;'>下一步骤：</td><td>");
								int i = 0;
								for(Iterator iter = steps.iterator();iter.hasNext();)
								{
									StepEntity entity = (StepEntity)iter.next();
									if (i==0){
										sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' checked style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
									}
									else{
										sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
									}
									i++;
								}
								sb.append("</td></tr>");
							}
						}else if("2".equals(formColumn)){//如果是两列显示
							if (steps!=null)
							{
								sb.append("<tr><td style='text-align:right;width:120px;'>流程名称：</td><td colspan='3'><input type='text' id='flowname' name='flowname' value='"+flowtype.getFlowname()+"' style='border: 1px solid #999;padding: 5px;width:705px'></td>");
							}
							int j = 1;
							for (int i = 0; i < fieldList.size(); i++) {
								AutoFormsField field1 = fieldList.get(i);
								//是否页面显示
								if("0".equals(field1.getIsPageShow().toString())){
									//columnHidden += "<input type='hidden' id=\""+field1.getFieldName()+"\" name=\""+field1.getFieldName()+"\"/>";
									continue;
								}
								if(!field1.getFieldName().equals("ID")){//除了ID的添加
									if(j%2==1){
										sb.append("<tr>");
									}
									columns += field1.getFieldName() + ",";
									sb.append("<td align=\"right\">"+field1.getCnName()+"：</td>");
									sb.append("<td align=\"left\">");
									sb.append(getAddHtml(field1,entityTableId));
									sb.append("</td>");
									if(j%2==0){
										sb.append("</tr>");
									}
									j++;
								}
							}
							//列表展示
							String columnName = formnew1.getColumnCnName();
							String columnSql = formnew1.getColumnSql();
							String specialColumn = formnew1.getSpecialColumn();  //显示信息 1：样品/检测项目 2：人员分配 3：原始记录分配 4：报告分配
							Long specialType = formnew1.getSpecialType();   //操作类型  1：编辑  2：查看
							
							
							if(!StringUtil.isEmpty(columnName) && !StringUtil.isEmpty(columnSql)){
								String tablenum = String.valueOf(k);
								tablejs += FormHandler.getTableJS(String.valueOf(formnew1.getId()),tablenum, columnName,columnSql,formnew1.getColumnWidth(),"",false);
								getRequest().setAttribute("tablejs", tablejs);
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<table style=\"width: 90%;\" class=\"tableCont\">"); 
								sb.append("<tr>");
								sb.append("<td>"); 
								sb.append("<table id=\"gridTable"+tablenum+"\"></table>");
								sb.append("<div id=\"gridPager"+tablenum+"\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
							}		
							else if(!StringUtil.isEmpty(specialColumn)){
								//样品列表
								tablejs += FormHandler.getSampleTable(flowtaskId);
								//检测项目列表
								tablejs += FormHandler.getItemeTable(flowtaskId,"0",String.valueOf(specialType));
								//其他检测项目列表
								//tablejs += FormHandler.getItemeTable2(flowtaskId);
								
							    getRequest().setAttribute("tablejs", tablejs);
								//样品/检测项目 多tab页
								if("1".equals(specialColumn)){
									sb.append("<tr>");
									sb.append("<td colspan='4' align='center'>"); 
									sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
									sb.append("<div title='样       品' style='padding:10px'>");
									sb.append("<input id='saveBtn1' type='button'  value='添 加' onclick=\"addSampleGrid()\" class='form_bt_orange'/>\r\n");
									sb.append("<input id='updateBtn1' type='button'  value='修 改'  onclick=\"updateSampleGrid()\" class='form_bt_orange'/>\r\n");
									sb.append("<input id='deleteBtn1' type='button'  value='删 除' onclick=\"deleteSampleGrid()\" class='form_bt_orange'/>\r\n");
									sb.append("<input id='deleteBtn1' type='button'  value='下载模版' onclick=\"downloadSampleModel()\" class='form_bt_orange'/>\r\n");
									sb.append("<input id='deleteBtn1' type='button'  value='模版导入' onclick=\"SampleModeImport()\" class='form_bt_orange'/>\r\n");
									sb.append("<table id=\"gridTableSample\"></table>");
									sb.append("<div id=\"gridPagerSample\"></div>");
									sb.append("</div>");
									sb.append("<div title='检测项目' style='padding:10px'>");
									sb.append("<input id='selectBtn2' type='button'  value='选择项目' onclick=\"selectItemGrid()\" class='form_bt_orange'/> &nbsp;\r\n");
									sb.append("<input id='deleteBtn2' type='button'  value='删 除' onclick=\"deleteItemGrid()\" class='form_bt_orange'/> &nbsp;\r\n");
									sb.append("<input id='saveBtn2' type='button'  value='保存列表' onclick=\"saveItemGrid(0)\" class='form_bt_orange'/> &nbsp;\r\n");
							//		sb.append("<input id='saveBtn2' type='button'  value='上传附件' onclick=\"itemGrid1UploadFile('gridTableItem1','0')\" class='form_bt_orange'/> &nbsp;\r\n");
									sb.append("<table id=\"gridTableItem1\"></table>");
									sb.append("<div id=\"gridPagerItem1\"></div>");
									sb.append("</div>");
//									sb.append("<div title='其他检测项目' style='padding:10px'>");
//									sb.append("<input id='addBtn3' type='button'  value='添 加' onclick=\"addRowtoItem2()\" class='form_bt_orange'/>&nbsp;\r\n");
//									sb.append("<input id='deleteBtn3' type='button'  value='删 除' onclick=\"deleteGridItem3()\" class='form_bt_orange'/> &nbsp;\r\n");
//									sb.append("<input id='saveBtn3' type='button'  value='保存列表'  onclick=\"saveGridOtherItem(0)\" class='form_bt_orange'/> &nbsp;\r\n");
//									sb.append("<input id='saveBtn3' type='button'  value='存入数据库' onclick=\"saveDataIntoItem()\" class='form_bt_orange'/> &nbsp;\r\n");
//							//		sb.append("<input id='saveBtn2' type='button'  value='上传附件' onclick=\"itemGrid1UploadFile('gridTableItem2','0')\"  class='form_bt_orange'/> &nbsp;\r\n");
//									sb.append("<table id=\"gridTableItem2\"></table>");
//									sb.append("<div id=\"gridPagerItem2\"></div>");
//									sb.append("</div>");
								    sb.append("</td>");
									sb.append("</tr>");
								}
							}
				
							if (steps!=null)
							{
								String isshow = "";
								if (steps.size()<=1)
								{
									isshow = "none";
								}
								sb.append("<td style='display:"+isshow+";text-align:right;width:120px;'>下一步骤：</td><td style='display:"+isshow+";'>");
								int i = 0;
								for(Iterator iter = steps.iterator();iter.hasNext();)
								{
									StepEntity entity = (StepEntity)iter.next();
									if (i==0){
										sb.append("<input type='radio' name='steptype' id='steptype"+i+"' checked style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;' value='"+entity.getId()+"'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
									}
									else{
										sb.append("<input type='radio' name='steptype' id='steptype"+i+"'  style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;' value='"+entity.getId()+"'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;");
									}
									i++;
								}
								sb.append("</td></tr>");
							}
						}
						sb.append("<table width='100%' border='0' align='center' class='formTableNew'>\r\n");
						sb.append("<td align='center' >\r\n");
						
						/**********************************按钮生成 列表　START***************************************/
						//关联的外键值是序列+1
						//String asql = "select SEQ_"+formnew.getFormEnName()+".currval from dual";
						//List waijianList = autoService.getDatabySql(asql);
						//关联的外键值是序列+1
						//waijianValue = Long.parseLong(waijianList.get(0).toString()) + 1; 
						String buttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 1 ";
						List buttonList = autoService.getDatabySql(buttonSql);
						if(buttonList != null && buttonList.size() != 0 ){
							for (int j = 0; j < buttonList.size(); j++) {
								Object[] obj = (Object[])buttonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" value=\""+obj[0]+"\" onclick=\"buttonOnclick("+obj[1]+",'"+obj[0]+"','"+obj[2]+"','"+obj[3]+"')\"/>\r\n");
							}
						}
						/**********************************按钮生成　END***************************************/
						
						/**********************************选择设备　START***************************************/
						String sheBeibuttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 6 ";
						List sheBeiButtonList = autoService.getDatabySql(sheBeibuttonSql);
						if(sheBeiButtonList != null && sheBeiButtonList.size() != 0 ){
							for (int j = 0; j < sheBeiButtonList.size(); j++) {
								Object[] obj = (Object[])sheBeiButtonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" value=\""+obj[0]+"\" onclick=\"chooseEquipment("+obj[1]+",'"+obj[0]+"','"+obj[2]+"','"+obj[3]+"')\"/>\r\n");
							}
						}
						/**********************************选择设备　END***************************************/
						
						/**********************************生成其他按钮　START***************************************/
						String otherSql = " select t.id, t.button_name,t.mode_path,t.choose_form_id from print_report_mode t where t.choose_form_id = "+formid;
						List otherList = autoService.getDatabySql(otherSql);
						if(otherList != null && otherList.size() != 0 ){
							for (int j = 0; j < otherList.size(); j++) {
								Object[] obj = (Object[])otherList.get(j);
								if("委托单打印".equals(obj[1].toString())){
								  sb.append("<input type=\"hidden\" class=\"form_bt_orange\" id=\"printwtd\" style=\"width:120px;\" value=\""+obj[1]+"\" onclick=\"viewOtherForm('"+obj[2]+"','"+obj[0]+"',"+obj[3]+",'"+obj[1]+"')\"/>\r\n");
								}else{
									sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[1]+"\" onclick=\"viewOtherForm('"+obj[2]+"','"+obj[0]+"',"+obj[3]+",'"+obj[1]+"')\"/>\r\n");
								}
							}
						}
						/**********************************生成其他按钮　END***************************************/
						sb.append("<input id='savesaveBtn' type='button'  value='保 存' class='form_bt_orange' />\r\n");
						sb.append("<input id='saveBtn' type='button'  value='提 交' class='form_bt_orange' />\r\n");
						sb.append("<input type='button' id='closeBtn' value='关 闭' class='form_bt_grey' />\r\n");
						sb.append("</td>\r\n");
						sb.append("</table>\r\n");
						sb.append(columnHidden);
					
				}
				sb.append("</table>\r\n");
				sb.append("</div>\r\n");
				sb.append(columnHidden);
			sb.append("</div>\r\n");
			//选择当前tab
			String formname = formnew.getFormCnName();
			sb.append("<script type='text/javascript'>\r\n");
			sb.append("$(document).ready(function(){");
			sb.append("$('#tt').tabs('select', '"+formname+"')"); 
			sb.append( "})");
			sb.append("</script>\r\n");
			
			String uploadfileFiled ="";
			//查询上传文件的字段
			String queryFiledSql ="select  wmsys.wm_concat(t.field_name) from auto_forms_field t where t.is_read_only =0 and t.page_display_type =13 and t.is_page_show =1 and t.forms_id="+formid;
			List queryFiledList = autoFormService.getDatabySql(queryFiledSql);
			if(null!=queryFiledList&&queryFiledList.size()>0&&null!=queryFiledList.get(0)){
				uploadfileFiled = queryFiledList.get(0).toString();
			}
			
			getRequest().setAttribute("flowtaskId",flowtaskId);System.out.println("--------生成flowtaskid-----------"+flowtaskId);
			getRequest().setAttribute("uploadfileFiled",uploadfileFiled);
			this.getRequest().setAttribute("flowid", flowid);
			getRequest().setAttribute("columns", columns);
			getRequest().setAttribute("tableContent", sb);
			getRequest().setAttribute("formnew", formnew);
			//getRequest().setAttribute("fieldList", fieldList);
			getRequest().setAttribute("formid", formid);
			getRequest().setAttribute("stateid", stateid);
			getRequest().setAttribute("waijianValue", waijianValue);
			getRequest().setAttribute("entityTableId", entityTableId);
			return "gotoDetail";
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	
	/**
	 * 初始化修改流程方法
	 * @return
	 */
	public String initUpdateOne()  throws IOException{ 
		
		String flowtaskinfoid = getRequest().getParameter("flowtaskinfoid");
		String stateid = this.getRequest().getParameter("stateid");
		//String formid = this.getRequest().getParameter("formid");
		String flowid = this.getRequest().getParameter("flowid");
		String taskId = this.getRequest().getParameter("taskid");
		String flag = this.getRequest().getParameter("flag");
		
		FlowTask flowTask = codeReviewService.getFlowTaskById(Long.parseLong(taskId));
		flowtype = codeReviewService.findFileNameById(Long.parseLong(flowid));
		String filename = flowtype.getFilename();
		String path = PubMethod.GetFlowFilePath()+filename;
		TotalFlowXmlTool fxs = new TotalFlowXmlTool(path);
		
		List<Flowstate> formidlist = fxs.GetFormlists();
		int k=0;
		//取得当前节点的formid
		Flowstate flowstate1 = fxs.GetFlowBeginState();
		//Flowstate flowstate1 = fxs.GetFlowStateByID(stateid);
		String formid = flowstate1.getForm().split(",")[0];
		AutoFormsNew formnew =  autoFormService.getAutoFormsNewById(flowstate1.getForm().split(",")[0]);
		
		List<StepEntity> steps = fxs.GetListByText(stateid);
		String columns = "";
		Object objs = null;//查询对象
		String functionuser = "";
		String tablejs = "";//拼接表单中的列表
		StringBuffer sb = new StringBuffer();
		sb.append("<div id='tt' class='easyui-tabs' style='width:"+formnew.getFormwidth()+"px'>");
		String columnHidden ="";
		try {
				Flowstate flowstate = formidlist.get(k);
				//查询表单信息
				AutoFormsNew formnew1 =  autoFormService.getAutoFormsNewById(formid);
				//查询字段信息
				List<AutoFormsField> fieldList = autoFormService.getAutoFormsFieldByformid(formid);
				
				if(fieldList.size()>0){//如果字段信息为空
					if((flowstate1.getForm().split(",")[0]).equals(formid)){
						String formColumn = String.valueOf(formnew1.getFormColumn());
						sb.append("<div title='"+formnew1.getFormCnName()+"' style='padding:20px;'>\r\n");
						sb.append("<table width='100%' border='0' align='center' class='formTableNew'>\r\n");
						
						if("1".equals(formColumn) || formnew1.getFormColumn()==null){//如果是一列显示
							if (steps!=null)
							{
								sb.append("<tr><td style='text-align:right;width:120px;'>流程名称：</td><td colspan='3'><input type='text' id='flowname' name='flowname' value='"+flowTask.getFlowName()+"' style='border: 1px solid #999;padding: 5px;width:705px'></td>");
							}
							for(AutoFormsField field : fieldList){
								//============================= 查询具体某个字段的值 START =============================
								String sql = "select "+field.getFieldName()+" from " + formnew.getFormEnName() + " where ID = "+flowTask.getMainId();
								List list = autoService.getDatabySql(sql);//查询所有的数据项
								if(list.size()>0){
									objs = (Object)list.get(0);
									if(objs == null || "".equals(objs)){
										objs = "";
									}
								}
								//============================= 查询具体某个字段的值 END =============================
								//页面是否显示
								if("0".equals(field.getIsPageShow().toString())){
									//columnHidden += "<input type='hidden' id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+objs+"\"  />";
									continue;
								}
								if(!field.getFieldName().equals("ID")){//除了ID的添加
									columns += field.getFieldName() + ",";
									sb.append("<tr>");
									sb.append("<td align=\"right\">"+field.getCnName()+"：</td>");
									sb.append("<td align=\"left\">");
									sb.append(getUpdateHtmlOne(field, objs,String.valueOf(flowTask.getMainId())));
									sb.append("</td>");
									sb.append("</tr>");
								}
							}
							String columnName = formnew1.getColumnCnName();
							String specialColumn = formnew1.getSpecialColumn();
							Long specialColumnType = formnew1.getSpecialType();
							String specialType = formnew1.getSpecialType()!=null?formnew1.getSpecialType().toString():"";
							if("1".equals(specialColumn)){
								//样品列表
								tablejs += FormHandler.getSampleTable(String.valueOf(flowTask.getId()));
								//检测项目列表
								tablejs += FormHandler.getItemeTable(String.valueOf(flowTask.getId()),"",specialType);
								//其他检测项目列表
								//tablejs += FormHandler.getItemeTable2(String.valueOf(flowTask.getId()));
						
								
							    getRequest().setAttribute("tablejs", tablejs);
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样       品' style='padding:10px'>");
								sb.append("<input id='saveBtn1' type='button'  value='添 加' onclick=\"addSampleGrid()\" class='form_bt_orange'/>\r\n");
								sb.append("<input id='updateBtn1' type='button'  value='修 改'  onclick=\"updateSampleGrid()\" class='form_bt_orange'/>\r\n");
								sb.append("<input id='deleteBtn1' type='button'  value='删 除' onclick=\"deleteSampleGrid()\" class='form_bt_orange'/>\r\n");
								sb.append("<input id='deleteBtn1' type='button'  value='下载模版' onclick=\"downloadSampleModel()\" class='form_bt_orange'/>\r\n");
								sb.append("<input id='deleteBtn1' type='button'  value='模版导入' onclick=\"SampleModeImport()\" class='form_bt_orange'/>\r\n");
								sb.append("<table id=\"gridTableSample\"></table>");
								sb.append("<div id=\"gridPagerSample\"></div>");
								sb.append("</div>");
								sb.append("<div title='检测项目' style='padding:10px'>");
								sb.append("<input id='selectBtn2' type='button'  value='选择项目' onclick=\"selectItemGrid()\" class='form_bt_orange'/> &nbsp;\r\n");
								sb.append("<input id='deleteBtn2' type='button'  value='删 除' onclick=\"deleteItemGrid()\" class='form_bt_orange'/> &nbsp;\r\n");
								sb.append("<input id='saveBtn2' type='button'  value='保存列表' onclick=\"saveItemGrid(0)\" class='form_bt_orange'/> &nbsp;\r\n");
						//		sb.append("<input id='saveBtn2' type='button'  value='上传附件' onclick=\"itemGrid1UploadFile('gridTableItem1','0')\" class='form_bt_orange'/> &nbsp;\r\n");
								sb.append("<table id=\"gridTableItem1\"></table>");
								sb.append("<div id=\"gridPagerItem1\"></div>");
								sb.append("</div>");
//								sb.append("<div title='其他检测项目' style='padding:10px'>");
//								sb.append("<input id='addBtn3' type='button'  value='添 加' onclick=\"addRowtoItem2()\" class='form_bt_orange'/>&nbsp;\r\n");
//								sb.append("<input id='deleteBtn3' type='button'  value='删 除' onclick=\"deleteGridItem3()\" class='form_bt_orange'/> &nbsp;\r\n");
//								sb.append("<input id='saveBtn3' type='button'  value='保存列表'  onclick=\"saveGridOtherItem(0)\" class='form_bt_orange'/> &nbsp;\r\n");
//								sb.append("<input id='saveBtn3' type='button'  value='存入数据库' onclick=\"saveDataIntoItem()\" class='form_bt_orange'/> &nbsp;\r\n");
//						//		sb.append("<input id='saveBtn2' type='button'  value='上传附件' onclick=\"itemGrid1UploadFile('gridTableItem2','0')\"  class='form_bt_orange'/> &nbsp;\r\n");
//								sb.append("<table id=\"gridTableItem2\"></table>");
//								sb.append("<div id=\"gridPagerItem2\"></div>");
//								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
							}
							else if("2".equals(specialColumn)){
								String deptid = getDeptid();
//								tableuser = FormHandler.getUserTable(String.valueOf(flowTask.getMainId()),deptid,String.valueOf(flowTask.getDeptSeq()));
//								functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),deptid);
//								getRequest().setAttribute("functionuser", functionuser);
//								getRequest().setAttribute("tableuser", tableuser);
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								
								sb.append("<table style=\"width: 100%;\">"); 
								sb.append("<tr>");
								sb.append("<td align='center'>"); 
								sb.append("<input type='button' value='分配用户' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
								sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
								sb.append("<table width='100%' id=\"gridTableUser\"></table>");
								sb.append("<div id=\"gridPagerUser\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
								
							}else if("3".equals(specialColumn)){//选择原始记录
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								
								getRequest().setAttribute("tablejs", tablejs);
                                functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid(),flowtaskinfoid);
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								if("1".equals(specialType)){//编辑
									sb.append("<input type='button' value='原始记录' onclick=\"openYsjl('0')\" class='form_bt_orange' style='width:120px;'/>");
									//常规检测流程
									if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))){
										sb.append("&nbsp;&nbsp;<input type='button' value='上传附件' onclick=\"itemGrid1UploadFile('gridTableSampleItem','1')\" class='form_bt_orange' style='width:120px;'/>");
										sb.append("&nbsp;&nbsp;<input type='button' value='查看附件' onclick=\"downloaYsjlAnnex('gridTableSampleItem',1)\" class='form_bt_orange' style='width:120px;'/>");
										sb.append("&nbsp;&nbsp;<input type='button' value='删除附件' onclick=\"deleteYsjlAnnex('gridTableSampleItem')\" class='form_bt_orange' style='width:120px;'/>");
									}
								}else{//查看
									sb.append("<input type='button' value='原始记录单审核' onclick=\"openYsjl('1')\" class='form_bt_orange' style='width:120px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								
								
								
								
								 
							}else if("4".equals(specialColumn)){//选择报告
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('hideCol','T_JIANCEYUANNAME');";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_BGFILEPATH');";
								//增加选择同名报告部门代码
								tablejs +="function rowselect(id){\n";
								tablejs +="var celldata = jQuery(\"#gridTableSampleItem\").jqGrid('getCell',id,'T_BGFILEPATH');\n";
								tablejs +="if (celldata!=''&&celldata!=undefined){\n";
								//tablejs +="jQuery(\"#gridTableSampleItem\").trigger('reloadGrid');\n";
								tablejs +="var ids = jQuery(\"#gridTableSampleItem\").jqGrid('getDataIDs');\n";
								tablejs +="for(var i=0;i<ids.length;i++){\n";
								tablejs +="var celldata1 = jQuery(\"#gridTableSampleItem\").jqGrid('getCell',ids[i],'T_BGFILEPATH');\n";
								tablejs +="if (celldata==celldata1 && id!=ids[i]){\n";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('setSelection',ids[i]);\n";
								tablejs +="}\n";
								tablejs +="}\n";
								tablejs +="}\n";
								tablejs +="}\n";
								getRequest().setAttribute("tablejs", tablejs);
                                functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid(),flowtaskinfoid);
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								sb.append("<input type='button' value='查看原始记录' onclick=\"openYsjl('1')\" class='form_bt_orange' style='width:120px;'/>");
								
								if("1".equals(specialType)){//编辑
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='制作报告' onclick=\"openBg('0')\" class='form_bt_orange' style='width:100px;'/>");
								}else{//查看
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='查看报告' onclick=\"openBg('1')\" class='form_bt_orange' style='width:100px;'/>");
								}
								//常规检测流程---》报告与原始记录发放节点
								if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"bgysjlff".equals(stateid)){
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='报告与原始记录发放' onclick=\"bgAndysjlfafang()\" class='form_bt_orange' style='width:170px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								 
							}
							else if("5".equals(specialColumn)){//样品/检测项目列表
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    getRequest().setAttribute("tablejs", tablejs);

							    functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid(),flowtaskinfoid);
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								if("1".equals(specialType)){
									sb.append("<input type='button' value='分配用户' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
									sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
							}
							if (steps!=null)
							{
								String isshow = "";
								if (steps.size()<=1)
								{
									isshow = "none";
								}
								//sb.append("<tr style='display:"+isshow+";'><td style='text-align:right;'>下一步骤：</td><td>");
								//int i = 0;
								//for(Iterator iter = steps.iterator();iter.hasNext();)
								//{
								//	StepEntity entity = (StepEntity)iter.next();
								//	if (i==0){
								//		sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' checked style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
								//	}
								//	else{
								//		sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
								//	}
								//	i++;
								//}
								//sb.append("</td></tr>");
							}
						}else if("2".equals(formColumn)){//如果是两列显示
							if (steps!=null)
							{
								sb.append("<tr><td style='text-align:right;width:120px;'>流程名称：</td><td colspan='3'><input type='text' id='flowname' name='flowname' value='"+flowTask.getFlowName()+"' style='border: 1px solid #999;padding: 5px;width:705px'></td>");
							}
							int j = 1;
							
							for (int i = 0; i < fieldList.size(); i++) {
								AutoFormsField field1 = fieldList.get(i);
								if(!field1.getFieldName().equals("ID")){//除了ID的添加
									//============================= 查询具体某个字段的值 START =============================
									String sql = "select "+field1.getFieldName()+" from " + formnew.getFormEnName() + " where ID = "+flowTask.getMainId();
									List list = autoService.getDatabySql(sql);//查询所有的数据项
									if(list.size()>0){
										objs = (Object)list.get(0);
										if(objs == null || "".equals(objs)){
											objs = "";
										}
									}
									//页面是否显示
									if("0".equals(field1.getIsPageShow().toString())){
										//columnHidden += "<input type='hidden' id=\""+field1.getFieldName()+"\" name=\""+field1.getFieldName()+"\" value=\""+objs+"\"  />";
										continue;
									}
									//============================= 查询具体某个字段的值 END =============================
									if(j%2==1){
										sb.append("<tr>");
									}
									columns += field1.getFieldName() + ",";
									sb.append("<td align=\"right\">"+field1.getCnName()+"：</td>");
									sb.append("<td align=\"left\">");
									sb.append(getUpdateHtmlOne(field1, objs,String.valueOf(flowTask.getMainId())));
									sb.append("</td>");
									if(j%2==0){
										sb.append("</tr>");
									}
									j++;
								}
							}
							String columnName = formnew1.getColumnCnName();
							String specialColumn = formnew1.getSpecialColumn();
							Long specialColumnType = formnew1.getSpecialType();
							String specialType = formnew1.getSpecialType()!=null?formnew1.getSpecialType().toString():"";
							if("1".equals(specialColumn)){
								//样品列表
								tablejs += FormHandler.getSampleTable(String.valueOf(flowTask.getId()));
								//检测项目列表
								tablejs += FormHandler.getItemeTable(String.valueOf(flowTask.getId()),"0",specialType);
								//其他检测项目列表
								//tablejs += FormHandler.getItemeTable2(String.valueOf(flowTask.getId()));
						
								
							    getRequest().setAttribute("tablejs", tablejs);
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样       品' style='padding:10px'>");
								sb.append("<input id='saveBtn1' type='button'  value='添 加' onclick=\"addSampleGrid()\" class='form_bt_orange'/>\r\n");
								sb.append("<input id='updateBtn1' type='button'  value='修 改'  onclick=\"updateSampleGrid()\" class='form_bt_orange'/>\r\n");
								sb.append("<input id='deleteBtn1' type='button'  value='删 除' onclick=\"deleteSampleGrid()\" class='form_bt_orange'/>\r\n");
								sb.append("<input id='deleteBtn1' type='button'  value='下载模版' onclick=\"downloadSampleModel()\" class='form_bt_orange'/>\r\n");
								sb.append("<input id='deleteBtn1' type='button'  value='模版导入' onclick=\"SampleModeImport()\" class='form_bt_orange'/>\r\n");
								sb.append("<table id=\"gridTableSample\"></table>");
								sb.append("<div id=\"gridPagerSample\"></div>");
								sb.append("</div>");
								sb.append("<div title='检测项目' style='padding:10px'>");
								sb.append("<input id='selectBtn2' type='button'  value='选择项目' onclick=\"selectItemGrid()\" class='form_bt_orange'/> &nbsp;\r\n");
								sb.append("<input id='deleteBtn2' type='button'  value='删 除' onclick=\"deleteItemGrid()\" class='form_bt_orange'/> &nbsp;\r\n");
								sb.append("<input id='saveBtn2' type='button'  value='保存列表' onclick=\"saveItemGrid(0)\" class='form_bt_orange'/> &nbsp;\r\n");
						//		sb.append("<input id='saveBtn2' type='button'  value='上传附件' onclick=\"itemGrid1UploadFile('gridTableItem1','0')\" class='form_bt_orange'/> &nbsp;\r\n");
								sb.append("<table id=\"gridTableItem1\"></table>");
								sb.append("<div id=\"gridPagerItem1\"></div>");
								sb.append("</div>");
//								sb.append("<div title='其他检测项目' style='padding:10px'>");
//								sb.append("<input id='addBtn3' type='button'  value='添 加' onclick=\"addRowtoItem2()\" class='form_bt_orange'/>&nbsp;\r\n");
//								sb.append("<input id='deleteBtn3' type='button'  value='删 除' onclick=\"deleteGridItem3()\" class='form_bt_orange'/> &nbsp;\r\n");
//								sb.append("<input id='saveBtn3' type='button'  value='保存列表'  onclick=\"saveGridOtherItem(0)\" class='form_bt_orange' /> &nbsp;\r\n");
//								sb.append("<input id='saveBtn3' type='button'  value='存入数据库' onclick=\"saveDataIntoItem()\" class='form_bt_orange'/> &nbsp;\r\n");
//						//		sb.append("<input id='saveBtn2' type='button'  value='上传附件' onclick=\"itemGrid1UploadFile('gridTableItem2','0')\"  class='form_bt_orange'/> &nbsp;\r\n");
//								sb.append("<table id=\"gridTableItem2\"></table>");
//								sb.append("<div id=\"gridPagerItem2\"></div>");
//								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
							}else if("2".equals(specialColumn)){
								String deptid = getDeptid();
//								tableuser = FormHandler.getUserTable(String.valueOf(flowTask.getMainId()),deptid,String.valueOf(flowTask.getDeptSeq()));
//								functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),deptid);
//								getRequest().setAttribute("functionuser", functionuser);
//								getRequest().setAttribute("tableuser", tableuser);
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								
								sb.append("<table style=\"width: 100%;\">"); 
								sb.append("<tr>");
								sb.append("<td align='center'>"); 
								sb.append("<input type='button' value='分配用户' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
								sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
								sb.append("<table width='100%' id=\"gridTableUser\"></table>");
								sb.append("<div id=\"gridPagerUser\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
								
							}else if("3".equals(specialColumn)){//选择原始记录
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								
								getRequest().setAttribute("tablejs", tablejs);
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								if("1".equals(specialType)){//编辑
									sb.append("<input type='button' value='原始记录' onclick=\"openYsjl('0')\" class='form_bt_orange' style='width:120px;'/>");
									//常规检测流程
									if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))){
										sb.append("&nbsp;&nbsp;<input type='button' value='上传附件' onclick=\"itemGrid1UploadFile('gridTableSampleItem','1')\" class='form_bt_orange' style='width:120px;'/>");
										sb.append("&nbsp;&nbsp;<input type='button' value='查看附件' onclick=\"downloaYsjlAnnex('gridTableSampleItem',1)\" class='form_bt_orange' style='width:120px;'/>");
										sb.append("&nbsp;&nbsp;<input type='button' value='删除附件' onclick=\"deleteYsjlAnnex('gridTableSampleItem')\" class='form_bt_orange' style='width:120px;'/>");
									}
								}else{//查看
									sb.append("<input type='button' value='原始记录单审核' onclick=\"openYsjl('1')\" class='form_bt_orange' style='width:120px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								
								
								
								
								 
							}else if("4".equals(specialColumn)){//选择报告
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('hideCol','T_JIANCEYUANNAME');";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_BGFILEPATH');";
								//增加选择同名报告部门代码
								tablejs +="function rowselect(id){\n";
								tablejs +="var celldata = jQuery(\"#gridTableSampleItem\").jqGrid('getCell',id,'T_BGFILEPATH');\n";
								tablejs +="if (celldata!=''&&celldata!=undefined){\n";
								//tablejs +="jQuery(\"#gridTableSampleItem\").trigger('reloadGrid');\n";
								tablejs +="var ids = jQuery(\"#gridTableSampleItem\").jqGrid('getDataIDs');\n";
								tablejs +="for(var i=0;i<ids.length;i++){\n";
								tablejs +="var celldata1 = jQuery(\"#gridTableSampleItem\").jqGrid('getCell',ids[i],'T_BGFILEPATH');\n";
								tablejs +="if (celldata==celldata1 && id!=ids[i]){\n";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('setSelection',ids[i]);\n";
								tablejs +="}\n";
								tablejs +="}\n";
								tablejs +="}\n";
								tablejs +="}\n";
								getRequest().setAttribute("tablejs", tablejs);
//                                functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid());
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								sb.append("<input type='button' value='查看原始记录' onclick=\"openYsjl('1')\" class='form_bt_orange' style='width:120px;'/>");
								
								if("1".equals(specialType)){//编辑
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='制作报告' onclick=\"openBg('0')\" class='form_bt_orange' style='width:100px;'/>");
								}else{//查看
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='查看报告' onclick=\"openBg('1')\" class='form_bt_orange' style='width:100px;'/>");
								}
								//常规检测流程---》报告与原始记录发放节点
								if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"bgysjlff".equals(stateid)){
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='报告与原始记录发放' onclick=\"bgAndysjlfafang()\" class='form_bt_orange' style='width:170px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								 
							}
							else if("5".equals(specialColumn)){//样品/检测项目列表
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    getRequest().setAttribute("tablejs", tablejs);

//							    functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid());
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								if("1".equals(specialType)){
									sb.append("<input type='button' value='分配用户' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
									sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
							}
							if (steps!=null)
							{
								//sb.append("<tr><td style='text-align:right;width:120px;'>流程名称：</td><td><input type='text' id='flowname' name='flowname' value='"+flowTask.getFlowName()+"'></td>");
								String isshow = "";
								if (steps.size()<=1)
								{
									isshow = "none";
								}
//								sb.append("<td style='display:"+isshow+";text-align:right;width:120px;'>下一步骤：</td><td style='display:"+isshow+";'>");
//								int i = 0;
//								for(Iterator iter = steps.iterator();iter.hasNext();)
//								{
//									StepEntity entity = (StepEntity)iter.next();
//									if (i==0){
//										sb.append("<input type='radio' name='steptype' id='steptype"+i+"' checked style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;' value='"+entity.getId()+"'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
//									}
//									else{
//										sb.append("<input type='radio' name='steptype' id='steptype"+i+"'  style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;' value='"+entity.getId()+"'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;");
//									}
//									i++;
//								}
//								sb.append("</td></tr>");
							}
						}
						sb.append("<table width='100%' border='0' align='center' class='formTableNew'>\r\n");
						sb.append("<td align='center' >\r\n");
						
						/**********************************按钮生成 列表　START***************************************/
						String buttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type,t.fitter_condition from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 1 ";
						List buttonList = autoService.getDatabySql(buttonSql);
						if(buttonList != null && buttonList.size() != 0 ){
							for (int j = 0; j < buttonList.size(); j++) {
								Object[] obj = (Object[])buttonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"buttonOnclick("+obj[1]+",'"+obj[0]+"','"+obj[2]+"','"+obj[3]+"','"+obj[4]+"')\"/>\r\n");
							}
						}
						/**********************************按钮生成　END***************************************/
						/**********************************生成原始记录按钮　START***************************************/
						String ysjlSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 2 ";
						List ysjlList = autoService.getDatabySql(ysjlSql);
						if(ysjlList != null && ysjlList.size() != 0 ){
							for (int j = 0; j < ysjlList.size(); j++) {
								Object[] obj = (Object[])ysjlList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openYsjl("+obj[3]+")\"/>\r\n");
							}
						}
						/**********************************生成原始记录按钮　END***************************************/
						/**********************************生成军检原始记录按钮　START***************************************/
						String jjysjlSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 5 ";
						List jjysjlList = autoService.getDatabySql(jjysjlSql);
						if(jjysjlList != null && jjysjlList.size() != 0 ){
							for (int j = 0; j < jjysjlList.size(); j++) {
								Object[] obj = (Object[])jjysjlList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openjjYsjl("+obj[3]+")\"/>\r\n");
							}
						}
						/**********************************生成军检原始记录按钮　END***************************************/
						/**********************************生成合格证按钮　START***************************************/
						String hgzSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 3 ";
						List hgzList = autoService.getDatabySql(hgzSql);
						if(hgzList != null && hgzList.size() != 0 ){
							for (int j = 0; j < hgzList.size(); j++) {
								Object[] obj = (Object[])hgzList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openHgz("+obj[3]+")\"/>\r\n");
							}
						}
						/**********************************生成合格证按钮　END***************************************/
						
						/**********************************生成其他按钮 编辑　START***************************************/
						String otherSql = " select t.id, t.button_name,t.mode_path,t.choose_form_id from print_report_mode t where t.choose_form_id = "+formid;
						List otherList = autoService.getDatabySql(otherSql);
						if(otherList != null && otherList.size() != 0 ){
							for (int j = 0; j < otherList.size(); j++) {
								Object[] obj = (Object[])otherList.get(j);
								if("委托单打印".equals(obj[1].toString())){
									  sb.append("<input type=\"hidden\" class=\"form_bt_orange\" id=\"printwtd\" style=\"width:120px;\" value=\""+obj[1]+"\" onclick=\"viewOtherForm('"+obj[2]+"','"+obj[0]+"',"+obj[3]+",'"+obj[1]+"')\"/>\r\n");
								}else{
									sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[1]+"\" onclick=\"viewOtherForm('"+obj[2]+"','"+obj[0]+"',"+obj[3]+",'"+obj[1]+"')\"/>\r\n");
								}
							}
						}
						/**********************************生成其他按钮　END***************************************/
						
						/**********************************生成其他按钮 查看　START***************************************/
						String otherLook = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 4 ";
						List otherLookList = autoService.getDatabySql(otherLook);
						if(otherLookList != null && otherLookList.size() != 0 ){
							for (int j = 0; j < otherLookList.size(); j++) {
								Object[] obj = (Object[])otherLookList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openOtherLook("+obj[3]+")\"/>\r\n");
							}
						}
						/**********************************生成其他按钮　END***************************************/
						sb.append("<input id='saveBtn' type='button'  value='保 存' class='form_bt_orange' />\r\n");
						sb.append("<input id='submitBtn' type='button'  value='提 交' class='form_bt_orange' />\r\n");
						sb.append("<input type='button' id='closeBtn' value='取 消' class='form_bt_grey' />\r\n");
						sb.append("</td>\r\n");
						sb.append("</table>\r\n");
						sb.append(columnHidden);
					}else{
						if(null != formnew1 && null!= formnew1.getFormColumn()){
							String formColumn = String.valueOf(formnew1.getFormColumn());
							sb.append("<div title='"+formnew1.getFormCnName()+"' style='padding:20px;'>\r\n");
							sb.append("<table width='100%' border='0' align='center' class='formTableNew'>\r\n");
							if("1".equals(formColumn) || formnew1.getFormColumn()==null){//如果是一列显示
								for(AutoFormsField field : fieldList){
									//============================= 查询具体某个字段的值 START =============================
									String sql = "select "+field.getFieldName()+" from " + formnew.getFormEnName() + " where ID = "+flowTask.getMainId();
									List list = autoService.getDatabySql(sql);//查询所有的数据项
									if(list.size()>0){
										objs = (Object)list.get(0);
										if(objs == null || "".equals(objs)){
											objs = "";
										}
									}
									//============================= 查询具体某个字段的值 END =============================
									
									//页面是否显示
									if("0".equals(field.getIsPageShow().toString())){
										//columnHidden += "<input type='hidden' id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+objs+"\"  />";
										continue;
									}
									
									if(!field.getFieldName().equals("ID")){//除了ID的添加
										//columns += field.getFieldName() + ",";
										sb.append("<tr>");
										sb.append("<td align=\"right\">"+field.getCnName()+"：</td>");
										sb.append("<td align=\"left\">");
										sb.append(getUpdateHtmlNoIdAndName(field,objs.toString()));
										sb.append("</td>");
										sb.append("</tr>");
									}
								}
							}else if("2".equals(formColumn)){//如果是两列显示
								int j = 1;
								for (int i = 0; i < fieldList.size(); i++) {
									AutoFormsField field1 = fieldList.get(i);
									//============================= 查询具体某个字段的值 START =============================
									String sql = "select "+field1.getFieldName()+" from " + formnew.getFormEnName() + " where ID = "+flowTask.getMainId();
									List list = autoService.getDatabySql(sql);//查询所有的数据项
									if(list.size()>0){
										objs = (Object)list.get(0);
										if(objs == null || "".equals(objs)){
											objs = "";
										}
									}
									//============================= 查询具体某个字段的值 END =============================
									//页面是否显示
									if("0".equals(field1.getIsPageShow().toString())){
										//columnHidden += "<input type='hidden' id=\""+field1.getFieldName()+"\" name=\""+field1.getFieldName()+"\" value=\""+objs+"\"  />";
										continue;
									}
									
									if(!field1.getFieldName().equals("ID")){//除了ID的添加
										if(j%2==1){
											sb.append("<tr>");
										}
										//columns += field1.getFieldName() + ",";
										sb.append("<td align=\"right\">"+field1.getCnName()+"：</td>");
										sb.append("<td align=\"left\">");
										sb.append(getUpdateHtmlNoIdAndName(field1,objs));
										sb.append("</td>");
										if(j%2==0){
											sb.append("</tr>");
										}
										j++;
									}
								} 
							}
						}
						}
						
				}
				sb.append("</table>\r\n");
				sb.append("</div>\r\n");
				sb.append(columnHidden);
			sb.append("</div>\r\n");
			//选择当前tab
			String formname = formnew.getFormCnName();
			sb.append("<script type='text/javascript'>\r\n");
			sb.append("$(document).ready(function(){");
			sb.append("$('#tt').tabs('select', '"+formname+"')"); 
			sb.append( "})");
			sb.append("</script>\r\n");
			this.getRequest().setAttribute("flowid", flowid);
			getRequest().setAttribute("columns", columns);
			getRequest().setAttribute("tableContent", sb);
			getRequest().setAttribute("formnew", formnew);
			//getRequest().setAttribute("fieldList", fieldList);
			getRequest().setAttribute("taskId", taskId);
			getRequest().setAttribute("flowtaskinfoid", flowtaskinfoid);
			getRequest().setAttribute("flag", flag);
			getRequest().setAttribute("stateid", stateid);
			getRequest().setAttribute("waijianValue", flowTask.getMainId());
			getRequest().setAttribute("formid",formid);
			return "toformupdate";
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	/**
	 * 发起页流程修改的提交方法
	 * @throws Exception
	 */
	
	public void submitUpdateFormData() throws Exception{
		PrintWriter out = this.getResponse().getWriter();
		String flag = getRequest().getParameter("flag");
		
		try{
			
			//存文件
			List files = getUploadfile();
			if (files!=null)
			{
				for (int i = 0 ; i < files.size() ; i++) 
				{ 
					String fileName = (String) getUploadfileFileName().get(i);
					String fileType = fileName.substring((fileName.lastIndexOf("."))+1, fileName.length());
					File ff = new File(files.get(i).toString());
					if(ff.length()>0)
					{
						ActionContext ac = ActionContext.getContext();
				        ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
				        String url = PubMethod.GetFilepathfromproperties("zhiliangka");
				       // String url = sc.getRealPath("/") + File.separator + "autoannex" + File.separator + "file" + File.separator;
						//url += "\\"+fileName;
				        //String url = sc.getRealPath("/") + File.separator + "auto" + File.separator + "file" + File.separator;
						File file = new File(url);
						if ( ! (file.exists())  &&   ! (file.isDirectory()))  {
			                 boolean  creadok  =  file.mkdirs();
			                 if (creadok)  {
			                    System.out.println( " ok:创建文件夹成功！ " );
			                } else  {
			                    System.out.println( " err:创建文件夹失败！ " );                    
			                } 
			            } 
						String address = url + "/" + getUploadfileFileName().get(i);
						FileOutputStream fos = new FileOutputStream(address); 
						FileInputStream fis = new FileInputStream(files.get(i).toString()); 
						byte[] buffer = new byte[1024]; 
						int len = 0; 
						while ((len = fis.read(buffer)) > 0) 
						{ 
							fos.write(buffer, 0, len);
						} 
						fos.close();
						fis.close();
					}
				}
			}
			
			String flowtaskinfoid = getRequest().getParameter("flowtaskinfoid");
			String flowid = getRequest().getParameter("flowid");
			String taskid = getRequest().getParameter("taskId");
			String flowname = getRequest().getParameter("flowname");
			String stateid = getRequest().getParameter("stateid");
			FlowTask flowTask = codeReviewService.getFlowTaskById(Long.parseLong(taskid));
			String path = this.getPath(flowid);
			TotalFlowXmlTool fxs = new TotalFlowXmlTool(path);
			Flowstate beforflowstate = fxs.GetFlowStateByID(stateid);
 
		
			flowTask.setFlowName(flowname);
			List<Flowstate> listss = fxs.GetNextFlowStateByID(stateid);
			Flowstate flowstate = (Flowstate)listss.get(0);
			String formid = beforflowstate.getForm().split(",")[0];
			List<Flowstate> formidlist = fxs.GetFormlists();
			
			//===================================保存实例 START=======================================
			
			//取得字段类型是文件的元素
			List checkBoxList = new ArrayList();
			List fileColumnList = new ArrayList();
			List<AutoFormsField> fieldList = autoFormService.getAutoFormsFieldByformid(formid);
			for(int i = 0; i<fieldList.size();i++){
				AutoFormsField aff = fieldList.get(i);
				if("13".equals(aff.getPageDisplayType().toString())){
					fileColumnList.add(aff.getFieldName());
				}else if("5".equals(aff.getPageDisplayType().toString())){
					checkBoxList.add(aff.getFieldName());
				}
			}
			
			String columns = getRequest().getParameter("columns");//页面所有的列
			//查询表单信息
			Flowstate flowstate1 = fxs.GetFlowStateByID(stateid);
			AutoFormsNew formnew =  autoFormService.getAutoFormsNewById(flowstate.getForm().split(",")[0]);
			//String bsql = "ID,";//拼接sql语句
			String asql = "SEQ_"+formnew.getFormEnName()+".nextval,";
			String updateValues = "";
			String updateSql = "";
			int fileNameIndex = 0;
			if(columns != null){
				String[] columnss = columns.split(",");
				for(String column : columnss){
					String columnValue = "";
					if(fileColumnList.contains(column)){
						if(uploadfileFileName != null && !"".equals(uploadfileFileName.get(fileNameIndex))){
							columnValue = uploadfileFileName.get(fileNameIndex).toString();
							fileNameIndex++;
						}else{
							columnValue = getRequest().getParameter(column);
						}
					}else  if(checkBoxList.contains(column)){//如果是复选框
						String[] values = getRequest().getParameterValues(column);
						columnValue=org.apache.commons.lang.StringUtils.join(values,",");
					}else{
						columnValue = getRequest().getParameter(column);
					}
					//String columnValue = getRequest().getParameter(column);
					if(columnValue == null||"".equals(columnValue)){
						//常规检测流程 空值用—— ——代替
						if(PubMethod.GetFlowid("flow.changguiFlowId").equals(flowid)&&"3881".equals(formid)){
							asql += "'— —',";
						}else if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "4121".equals(formid)){
							asql += "'— —',";
						}else{
							asql += "'',";
						}
					}else{
						asql += "'" + columnValue +"',";
					}
					updateValues += column+"='"+columnValue+"',";
				}
				
				//String sql = "insert into "+formnew.getFormEnName()+"("+columns.substring(0,columns.length()-1)+")values("+asql.substring(0,asql.length()-1)+")";
				updateSql = "update "+ formnew.getFormEnName()+" t set " +updateValues.substring(0,updateValues.length()-1) +" where t.ID = '"+flowTask.getMainId()+"'";
				autoService.executeSql(updateSql);
			}
			
			//===================================保存实例 END=======================================
			XmlHelper xmlhelper = new XmlHelper();
			String nextUserId = "";
			String nextUserName ="";
			if("submit".equals(flag)){
				flowTask.setFlowStateId(flowstate.getStateid());
				flowTask.setFlowStateName(flowstate.getState());
				
				FlowTaskInfo flowTaskInfo = codeReviewService.getFlowTaskInfoById(Long.parseLong(flowtaskinfoid));
				
				//常规检测流程下一操作人是批准人
				if(PubMethod.GetFlowid("flow.changguiFlowId").equals(flowid)&&"3881".equals(formid)){
					String pizhunName="";
					String pizhurenId = getRequest().getParameter("T_PIZHUNREN");
					String userSql = " select t.username  from sys_users t where t.userid= "+pizhurenId;
					List userNameList = autoService.getDatabySql(userSql);
					if(null!=userNameList&&userNameList.size()>0&&null!=userNameList.get(0)){
						pizhunName = userNameList.get(0).toString();
					}
					nextUserId = pizhurenId;
					nextUserName = pizhunName;
					
				}else{
					if (!flowstate.getRoleIds().equals(""))
					{
						flowTask.setNextRolesId(","+flowstate.getRoleIds()+",");
						flowTaskInfo.setNextRolesId(","+flowstate.getRoleIds()+",");
						flowTask.setNextRolesName(flowstate.getRoleNames());
						flowTaskInfo.setNextRolesName(flowstate.getRoleNames());
					}else{
						flowTask.setNextRolesId("");
						flowTaskInfo.setNextRolesId("");
						flowTask.setNextRolesName("");
						flowTaskInfo.setNextRolesName("");
					}
					
					if (!flowstate.getUserIds().equals(""))
					{
						nextUserId = flowstate.getUserIds();
					}
					nextUserName = flowstate.getUserNames();
				}
				
				flowTask.setNextUsersId(","+nextUserId+",");
				flowTask.setNextUsersName(nextUserName);
				flowTask.setNextDept(flowstate.getDept());
				flowTask.setNextDeptid(flowstate.getDeptid());
				flowTask.setState(0l);
				String plantaskname = this.getRequest().getParameter("plantaskname");
				//保存状态信息
				String nodetype =beforflowstate.getNodetype();
				
				
				flowTaskInfo.setFlowStateId(flowstate.getStateid());
				flowTaskInfo.setFlowStateName(flowstate.getState());
				flowTaskInfo.setNextUsersId(","+nextUserId+",");
				flowTaskInfo.setNextUsersName(nextUserName);
				flowTaskInfo.setNextUsersName(flowstate.getUserNames());
				flowTaskInfo.setNextDept(flowstate.getDept());
				flowTaskInfo.setNextDeptid(flowstate.getDeptid());
				codeReviewService.updateFlowTaskInfo(flowTaskInfo);
			

				FlowDetailed flowdetail = new FlowDetailed();
				flowdetail.setFlowTaskId(Long.parseLong(taskid));
				flowdetail.setFlowTypeId(flowTask.getFlowTypeId());
				String userId = ServletActionContext.getRequest().getSession().getAttribute("TDM_USER_ID").toString();
				String userNm = ServletActionContext.getRequest().getSession().getAttribute("username").toString();
				flowdetail.setOperatorperson(userNm);
				flowdetail.setOperatorpersonId(Long.parseLong(userId));
				flowdetail.setStatusbeforeid(beforflowstate.getStateid());
				flowdetail.setStatusbefore(beforflowstate.getState());
				flowdetail.setStatusafterid(flowstate.getStateid());
				flowdetail.setStatusafter(flowstate.getState());
				flowdetail.setDeptid(Long.parseLong(this.getDeptid()));
				flowdetail.setOperatortime(new Timestamp(System.currentTimeMillis()));
				flowdetail.setActiontype("流程操作");
				if(null!=flowstate.getRoleIds() && !"".equals(flowstate.getRoleIds())){
					flowdetail.setNextRoleId(flowstate.getRoleIds());
				}
				if(null!=flowstate.getUserIds()&&!"".equals(flowstate.getUserIds())){
					flowdetail.setNextUserId(flowstate.getUserIds());
				}
				codeReviewService.saveFlowDetailed(flowdetail);
				codeReviewService.updateFlowTask(flowTask);
				
			}
			out.print("{\"result\":\"success\",\"taskid\":\""+flowTask.getId()+"\"}");
		}catch(Exception exp){
			exp.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}
	/**
	 * 拼接html語句(修改的)
	 * author:lishu	 2013-10-29
	 */
	public String  getUpdateHtmlOne(AutoFormsField field,Object obj,String entityTableId){
		StringBuffer sb = new StringBuffer();
		String xzgyId = "";
		String type = String.valueOf(field.getPageDisplayType());
		String isPageDisplay = field.getIsPageShow().toString();//是否页面显示（0：否，1：是）
		String isReadOnly = field.getIsReadOnly().toString();//页面是否只读（0：否，1：是）
		String kongjianType = ""; //页面元素 type： hidden 还是text
		String readOnlyText = ""; //是否只读 readonly="readonly"
		String eventType = field.getEventType();//事件类型
		String eventName = field.getEventName();//事件名称
		String event = "";
		if(!StringUtil.isEmpty(eventType)){
			event = eventType + "=\"" + eventName + "()\"";
		}
		
		String bitian = " ";
		String message = "";
		if("NUMBER".equals(field.getFieldType())){
			message = "只允许输入数字";
			bitian += "  class='easyui-numberbox'  missingMessage='"+message+"' ";
		}else{
			if("1".equals(field.getAuthenticationType())){
				message = "必填";
				bitian += " class='easyui-validatebox' ";
			}
		}
		if("1".equals(field.getAuthenticationType())){
			message = "必填";
			bitian += " required missingMessage='"+message+"' ";
		}
		String foreignColumnName = "";
		String foreignTableName = "";
		
		if(!StringUtil.isEmpty(field.getForeignTableName())){
				foreignColumnName = field.getForeignCloumn()+","+field.getForeignDisCloumn();
				foreignTableName = field.getForeignTableName();
		}else{
//			String sql1 = "select tt.foreign_cloumn,tt.foreign_dis_cloumn,tt.foreign_table_name  from auto_forms_field tt " +
//			        "where tt.field_name = '"+field.getFieldName()+"'  and tt.foreign_cloumn is not null and tt.foreign_table_name is not null and tt.foreign_dis_cloumn is not null " +
//			        "and tt.forms_id in (select t.id  from auto_forms_new t where t.form_en_name = (select a.form_en_name from auto_forms_new a where a.id = "+field.getFormsId()+"))";
//			List list1 =  autoFromsService.queryListBySql(sql1);
//			if(list1.size()>0){
//				Object[] obj1 = (Object[])list1.get(0);
//				foreignColumnName = obj1[0].toString()+","+obj1[1].toString();
//				foreignTableName = obj1[2].toString();
//			}
		}
		if(obj==null){
			obj = "";
		}
		
		
		if("1".equals(isPageDisplay)){
			kongjianType = "text";
		}else{
			kongjianType = "hidden";
		}
		if("1".equals(isReadOnly)){
			readOnlyText = "readonly=readonly";
		}else{
			readOnlyText = "";
		}
		String defaultValue = field.getDefaultValue();//獲取默認值
		//页面显示类型（0：文本，1：时间空间，2：下拉菜单，3：文本域,4：单选框，5：复选框，6：操作人，7操作部门，8操作时间）
		if("1".equals(type)){//时间空间
			if("1".equals(isReadOnly)){
				sb.append("<input "+readOnlyText+"   style=\"border: 1px solid #999;padding: 5px;width: 250px;\" type=\""+kongjianType+"\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\" "+bitian+"/>");
			}else{
				sb.append("<input "+readOnlyText+"  style=\"border: 1px solid #999;padding: 5px;width: 250px;\" type=\""+kongjianType+"\" id=\""+field.getFieldName()+"\" onClick=\"WdatePicker()\" name=\""+field.getFieldName()+"\" value=\""+obj+"\" "+bitian+"/>");
			}
		}else if("2".equals(type)){//下拉菜单
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				if("1".equals(isReadOnly)){
					sb.append("<select id=\""+field.getFieldName()+"\" disabled class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
				}else{
					sb.append("<select id=\""+field.getFieldName()+"\" class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
				}
				for(String value : values){
					if(value.equals(String.valueOf(obj))){
						sb.append("<option value=\""+value+"\" selected=selected>"+value+"</option>");
					}else{
						sb.append("<option value=\""+value+"\" >"+value+"</option>");
					}
				}
				sb.append("</select>");
			}
		}else if("3".equals(type)){//文本域
			if(null!=obj ){
				obj = htmlEscape(obj.toString());
			}
			sb.append("<textarea "+readOnlyText+" rows=\"8\"  class='ftextarea' cols=\"40\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" "+bitian+" >"+obj+"</textarea>");
		}else if("4".equals(type)){//单选框
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				for(String value : values){
					if("1".equals(isReadOnly)){
						if(obj!=null && value.equals(obj)){
							sb.append("<input type=\"radio\" disabled style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" checked=\"checked\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
						}else{
							sb.append("<input type=\"radio\" disabled style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
						}
					}else{
						if(obj!=null && value.equals(obj)){
							sb.append("<input type=\"radio\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" checked=\"checked\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
						}else{
							sb.append("<input type=\"radio\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
						}
					}
				}
			}
		}else if("5".equals(type)){//复选框
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				int j = 0;
				for (int i = 0; i < values.length; i++) {
					String realValue = ","+String.valueOf(obj)+",";
					if("1".equals(isReadOnly)){
						if(obj!=null && realValue.contains(values[i])){
							sb.append("<input type=\"checkbox\" disabled checked=\"checked\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+values[i]+"\"  "+bitian+">" + values[i]);
						}else{
							sb.append("<input type=\"checkbox\" disabled style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+values[i]+"\" "+bitian+">" + values[i]);
						}
					}else{
						if(obj!=null && realValue.contains(values[i])){
							sb.append("<input type=\"checkbox\" checked=\"checked\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+values[i]+"\"  "+bitian+">" + values[i]);
						}else{
							sb.append("<input type=\"checkbox\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+values[i]+"\" "+bitian+">" + values[i]);
						}
					}
					if(j%MOD_CHECK==1){
						sb.append("<br/>");
					}
					j++;
				} 
			}
		}else if("6".equals(type)){//操作人
			sb.append("<input type=\""+kongjianType+"\" class='finput'  readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+getUserNM()+"\" />");
		}else if("7".equals(type)){//操作部门
			if(obj == null || "".equals(obj) ){
				sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"   readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+getDeptName()+"\" />");
			}else{
				sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"   readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\" />");
			}
		}else if("8".equals(type)){//操作时间
			sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"   readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+DateUtilsAll.dateToString(new Date())+"\" "+bitian+"/>");
		}else if("9".equals(type)){//操作日期
      	    sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"   readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+DateUtilsAll.dateToStringShort(new Date())+"\" "+bitian+"/>");
		}else if("10".equals(type)){//选择部门
			if(obj == null || "".equals(obj) ){
				obj = "''";
			}
			//根据部门id去查询部门名称显示表单上
			String sqlDept = "select t.org_id,t.org_name from sys_organization t where t.org_name ='"+obj+"'";
			List listDept = autoService.getDatabySql(sqlDept);//查询所有的数据项
			Object[] objDept = null;
			if(listDept != null && listDept.size() != 0){
				objDept = (Object [])listDept.get(0);
				sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\"  value=\""+objDept[0]+"\">");
				sb.append("<input type=\"text\" class='finput'  readonly=readonly id=\"dept_"+field.getFieldName()+"\" name=\"dept_"+field.getFieldName()+"\" value=\""+objDept[1]+"\" "+bitian+"/>");
			}else{
				sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\">");
				sb.append("<input type=\"text\" class='finput'  readonly=readonly id=\"dept_"+field.getFieldName()+"\" name=\"dept_"+field.getFieldName()+"\" "+bitian+"/>");
			}
			//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectdept('"+field.getFieldName()+"')\" />");
			
			String whetherShow = "select tt.is_read_only,tt.id  from auto_forms_field tt  where tt.field_name = '"+field.getFieldName()+"'  and tt.forms_id ="+field.getFormsId()+" ";
			List list2 =  autoFormService.getDatabySql(whetherShow);
			if(list2!=null&&list2.size()>0){
				Object[] obj1 = (Object[])list2.get(0);
				if("0".equals(obj1[0].toString())){//否
					sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectdept('"+field.getFieldName()+"')\" />");
					
				}else{//是
					
				}
			}
		}else if("11".equals(type)){//选择人员
			//根据人员id查询人员姓名显示表单上
//			if(obj == null || "".equals(obj) ){
//				obj = "''";
//			}
//			String sqlPerson = "select t.userid,t.username from sys_users t where t.userid="+obj;
//			List listPerson = autoService.getDatabySql(sqlPerson);//查询所有的数据项
//			Object[] objPerson = null;
//			if(listPerson != null && listPerson.size() != 0){
//				objPerson = (Object [])listPerson.get(0);
//				sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\" value=\""+objPerson[0]+"\">");
//				sb.append("<input type=\"text\" readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+objPerson[1]+"\" "+bitian+"/>");
//			}else{
//				sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\">");
//				sb.append("<input type=\"text\" readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" "+bitian+"/>");
//			}
			if(obj!=null && !"".equals(obj) ){
					sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\">");
					sb.append("<input type=\"text\" class='finput' readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\"  class=\"tab_input\" "+bitian+"/>");
				//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
			}else{
				sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\">");
				sb.append("<input type=\"text\" class='finput' readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\"  class=\"tab_input\" "+bitian+"/>");
				//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
			}
			//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
			String whetherShow = "select tt.is_read_only,tt.id  from auto_forms_field tt  where tt.field_name = '"+field.getFieldName()+"'  and tt.forms_id ="+field.getFormsId()+" ";
			List list2 =  autoService.getDatabySql(whetherShow);;
			if(list2!=null&&list2.size()>0){
				Object[] obj1 = (Object[])list2.get(0);
				if("0".equals(obj1[0].toString())){//否
					sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
					
				}else{//是
					
				}
			}

		}else if(!"".equals(foreignColumnName)&&!"".equals(foreignTableName)){//如果不满足上述条件  则判断外键是否存在
			if(obj!=null && !"".equals(obj)){
				String sql2 = "select tt.foreign_cloumn,tt.foreign_dis_cloumn,tt.foreign_table_name  from auto_forms_field tt " +
				        "where tt.field_name = '"+field.getFieldName()+"'  and tt.foreign_cloumn is not null and tt.foreign_table_name is not null and tt.foreign_dis_cloumn is not null " +
				        "and tt.forms_id in (select t.id  from auto_forms_new t where t.form_en_name = (select a.form_en_name from auto_forms_new a where a.id = "+field.getFormsId()+"))";
				List list3 =  autoService.getDatabySql(sql2);
				if(!StringUtil.isEmpty(field.getForeignTableName())){
						foreignColumnName = field.getForeignCloumn()+","+field.getForeignDisCloumn();
						foreignTableName = field.getForeignTableName();
						
				}else if(null!=list3&&list3.size()>0){
					Object[] obj1 = (Object[])list3.get(0);
					foreignColumnName = obj1[0].toString()+","+obj1[1].toString();
					foreignTableName = obj1[2].toString();
				}
				//根据外键去查询外键表的id和显示值
				if(obj.equals("") || obj == null){
					obj = "''";
				}
				String sqlForeign = "select "+foreignColumnName+" from "+foreignTableName+" where ID = "+obj;
				List listForeign = autoService.getDatabySql(sqlForeign);//查询所有的数据项
				Object[] objForeign = null;
				if(listForeign != null && listForeign.size() != 0){
					objForeign = (Object [])listForeign.get(0);
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+objForeign[0]+"\">");
					sb.append("<input type=\"text\" class='finput' readonly=readonly id=\"data_"+field.getFieldName()+"\" name=\"data_"+field.getFieldName()+"\" value=\""+objForeign[1]+"\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
				}else{
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\">");
					sb.append("<input type=\"text\" class='finput' readonly=readonly id=\"data_"+field.getFieldName()+"\" name=\"data_"+field.getFieldName()+"\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
				}
				//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectData('"+field.getFieldName()+"','"+field.getForeignTableName()+"','"+field.getForeignCloumn()+"','"+field.getForeignDisCloumn()+"','"+field.getCnName()+"','"+field.getDefaultValue()+"')\" />");
				String whetherShow = "select tt.is_read_only,tt.id  from auto_forms_field tt  where tt.field_name = '"+field.getFieldName()+"'  and tt.forms_id ="+field.getFormsId()+" ";
				List list2 =  autoService.getDatabySql(whetherShow);;
				if(list2!=null&&list2.size()>0){
					Object[] obj1 = (Object[])list2.get(0);
					if("0".equals(obj1[0].toString())){//否
						sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectData('"+field.getFieldName()+"','"+field.getForeignTableName()+"','"+field.getForeignCloumn()+"','"+field.getForeignDisCloumn()+"','"+field.getCnName()+"','"+field.getDefaultValue()+"','"+field.getFormsId()+"')\" />");
						
					}else{//是
						
					}
				}
			}else{
				sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\">");
				sb.append("<input type=\"text\" readonly=readonly id=\"data_"+field.getFieldName()+"\" name=\"data_"+field.getFieldName()+"\" value=\"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
				sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectData('"+field.getFieldName()+"','"+field.getForeignTableName()+"','"+field.getForeignCloumn()+"','"+field.getForeignDisCloumn()+"','"+field.getCnName()+"','"+field.getDefaultValue()+"','"+field.getFormsId()+"')\" />");
			}
		}
		else if("12".equals(type)){//原始记录
			if(obj != null){
				if(obj != null && !"".equals(obj)){
					sb.append("<input type=\"button\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\"查看原始记录\" onclick=\"viewYsjl('"+obj+"')\" class=\"button_b\" />");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\"/>");
				}else{
					sb.append("<input type=\"button\" id=\"bjysjl\" name=\"bjysjl\" value=\"编辑原始记录\" class=\"button_b\" onclick=\"openYsjl('"+field.getFieldName()+"');\" "+bitian+"/>");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
				}
			}else{
			}
		}
		else if("13".equals(type)){//文件上传
			if("1".equals(isReadOnly)){
				sb.append(FormHandler.getUploadHtml(getRequest().getContextPath(),entityTableId,field.getFieldName(),"y"));
			}else{
				sb.append(FormHandler.getUploadHtml(getRequest().getContextPath(),entityTableId,field.getFieldName(),"n"));
			}
		}else if("14".equals(type)){//合格证
			if(obj != null){
				if(obj != null && !"".equals(obj)){
					sb.append("<input type=\"button\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\"查看合格证\" onclick=\"viewHgz('"+obj+"')\" "+bitian+" />");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\"/>");
				}else{
					sb.append("<input type=\"button\" id=\"bjhgz\" name=\"bjhgz\" value=\"编辑合格证\" class=\"button_b\" onclick=\"openHgz('"+field.getFieldName()+"');\" "+bitian+"/>");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
				}
			}else{
			}
		}else if("15".equals(type)){//产品编号
				sb.append("<textarea readonly=\"readonly\"  class='ftextarea' rows=\"6\" cols=\"40\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" >"+obj+"</textarea>");
			
		}else if("19".equals(type)){//编号规则
			if(obj==null || "".equals(obj)){
				String no = autoFormService.queryCunstomNumber(field.getCustomNum(), field.getCustomId());
				sb.append("<input type=\"text\" class='finput' readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+no+"\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
			}else{
				sb.append("<input type=\"text\"   id=\""+field.getFieldName()+"\"  name=\""+field.getFieldName()+"\" value=\""+obj+"\" readonly=\"readonly\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
			}
			
		}else if("20".equals(type)){//试验编号
			if(obj==null || "".equals(obj)){
				sb.append("<input type=\"text\"   id=\""+field.getFieldName()+"\"  name=\""+field.getFieldName()+"\" readonly=\"readonly\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
				sb.append("<input type=\"hidden\"   id=\"TEST_ID\"  name=\"TEST_ID\"  style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
				sb.append("<img src=\"web/images/form_icon_1.gif\" width=\"23\" height=\"23\" border=\"0\" onclick=\"chooseCustomNo('"+field.getFieldName()+"');\" title=\"选择\" style=\"margin-bottom:-6px;cursor:hand;\" />");
				
			}else{
				sb.append("<input type=\"text\"   id=\""+field.getFieldName()+"\"  name=\""+field.getFieldName()+"\" value=\""+obj+"\" readonly=\"readonly\"  "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
				sb.append("<img src=\"web/images/form_icon_1.gif\" width=\"23\" height=\"23\" border=\"0\" onclick=\"chooseCustomNo('"+field.getFieldName()+"');\" title=\"选择\" style=\"margin-bottom:-6px;cursor:hand;\" />");
			}
		}else if("21".equals(type)){//根据材料牌号自动变
			if("1".equals(isReadOnly)){
				sb.append("<select id=\""+field.getFieldName()+"\" disabled class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
			}else{
				sb.append("<select id=\""+field.getFieldName()+"\"  class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
			}
			sb.append("</select>");
		}else{
			if("ID".equals(field.getFieldName())){//如果是主键则隐藏
				sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\" />");
			}else{
				if(null!=obj ){
					obj = htmlEscape(obj.toString());
				}
				sb.append("<input "+readOnlyText+" "+event+" "+event+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\" type=\""+kongjianType+"\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\" "+bitian+"/>");
			}
		}
		return sb.toString();
	}
	/**
	 * 初始化添加页面，主要是自定义表单元素初始化，和下级操作节点初始化
	 * @return
	 */
	public String initCodeReviewUpdate()  throws IOException{
		
		String flowtaskinfoid = getRequest().getParameter("flowtaskinfoid");
		String stateid = this.getRequest().getParameter("stateid");
		//String formid = this.getRequest().getParameter("formid");
		String flowid = this.getRequest().getParameter("flowid");
		String taskId = this.getRequest().getParameter("taskid");
		String flag = this.getRequest().getParameter("flag");
		
		FlowTask flowTask = codeReviewService.getFlowTaskById(Long.parseLong(taskId));
	
		flowtype = codeReviewService.findFileNameById(Long.parseLong(flowid));
		String filename = flowtype.getFilename();
		String path = PubMethod.GetFlowFilePath()+filename;
		TotalFlowXmlTool fxs = new TotalFlowXmlTool(path);
		List<Flowstate> formidlist = fxs.GetFormlists();
		
		//取得当前节点的formid
		Flowstate flowstate1 = fxs.GetFlowStateByID(stateid);
		String formid = flowstate1.getForm().split(",")[0];
		AutoFormsNew formnew =  autoFormService.getAutoFormsNewById(flowstate1.getForm().split(",")[0]);
		List<StepEntity> steps = fxs.GetListByText(stateid);
		String columns = "";
		Object objs = null;//查询对象
		String tablejs = "";//拼接表单中的列表
		StringBuffer bodyjs = new StringBuffer();//事件js方法
		String functionjs = "";//拼接js方法
		String functionuser = "";
		String tabledept = "";
		String tableuser = "";
		String tablejsid = "";//拼接列表中外键id
		String functionYsjl = "";
		String tableYsjl = "";
		String functionYsjl1 = "";
		String tableYsjl1 = "";
		String functionBg = "";
		String tableBg = "";
		String functionBg1 = "";
		String tableBg1 = "";
		boolean flowstateid = false;
		StringBuffer sb = new StringBuffer();
		sb.append("<div id='tt' class='easyui-tabs' style='width:"+formnew.getFormwidth()+"px'>");
		String columnHidden ="";
		try {
				Flowstate flowstate = formidlist.get(0);
				flowstateid = (flowstate1.getForm().split(",")[0]).equals(flowstate.getForm());
				//查询表单信息
				AutoFormsNew formnew1 =  autoFormService.getAutoFormsNewById(formid);
				//查询字段信息
				List<AutoFormsField> fieldList = autoFormService.getAutoFormsFieldByformid(formid);
				if(fieldList.size()>0){//如果字段信息为空
					List fieldValues = autoFormService.getAutoFormsFieldValues(formid, formnew.getFormEnName(), String.valueOf(flowTask.getMainId()));
					Object[] values = (Object[])fieldValues.get(0);
					if(flowstateid){
						String formColumn = String.valueOf(formnew1.getFormColumn());
						sb.append("<div title='"+formnew1.getFormCnName()+"' style='padding:20px;'>\r\n");
						sb.append("<form action=\"\" id=\"pageFrom\" name=\"pageFrom\" method=\"post\">");
						sb.append("<table width='100%' border='0' align='center' class='formTableNew'>\r\n");
						
						if("1".equals(formColumn) || formnew1.getFormColumn()==null){//如果是一列显示
							if (steps!=null)
							{
								sb.append("<tr><td style='text-align:right;width:120px;'>流程名称：</td><td colspan='3'><input type='text' id='flowname' name='flowname' value='"+flowTask.getFlowName()+"' style='width:705px' readonly ='readonly' ></td>");
							}
							for (int i = 0; i < fieldList.size(); i++) {
								AutoFormsField field = fieldList.get(i);
								objs = values[i];
								if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))){
									if("—— ——".equals(String.valueOf(objs))){
										objs = null;
									}
								}
								if(formnew1.getColumnForigen() != null && field.getFieldName().toLowerCase().equals(formnew1.getColumnForigen().toLowerCase())){//外键的值
									tablejsid = String.valueOf(objs);
								}
								if(!field.getFieldName().equals("ID") && !"0".equals(field.getIsPageShow().toString())){//除了ID的添加
									columns += field.getFieldName() + ",";
									sb.append("<tr>");
									sb.append("<td align=\"right\">"+field.getCnName()+"：</td>");
									sb.append("<td align=\"left\">");
									sb.append(getUpdateHtml(field, objs,String.valueOf(flowTask.getMainId())));
									sb.append("</td>");
									sb.append("</tr>");
								}
								if(!StringUtil.isEmpty(field.getEventFunction())){
									bodyjs.append(field.getEventFunction());
								}
							}
							//列表展示
							String columnName = formnew1.getColumnCnName();
							String columnSql = formnew1.getColumnSql();
							String columnForigen = formnew1.getColumnForigen();
							if(!StringUtil.isEmpty(columnName) && !StringUtil.isEmpty(columnSql)){
								if("flow_task_id".equals(columnForigen.toLowerCase())){//如果外键是流程id
									tablejsid = String.valueOf(flowTask.getId());
								}
								String tablenum = String.valueOf(0);
								tablejs += FormHandler.getTableJS(String.valueOf(formnew1.getId()),tablenum, columnName,columnSql,formnew1.getColumnWidth(),tablejsid,flowstateid);
								getRequest().setAttribute("tablejs", tablejs);
								sb.append("<tr>");
								sb.append("<td colspan='2' align='center'>"); 
								sb.append("<table style=\"width: 90%;\" class=\"tableCont\">"); 
								sb.append("<tr>");
								sb.append("<td>"); 
								sb.append("<table id=\"gridTable"+tablenum+"\"></table>");
								sb.append("<div id=\"gridPager"+tablenum+"\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
							}
							//选择部门
							String specialColumn = formnew1.getSpecialColumn();
							String specialType = formnew1.getSpecialType()!=null?formnew1.getSpecialType().toString():"";
							Long specialColumnType = formnew1.getSpecialType();
							if("1".equals(specialColumn)){//项目列表
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样       品' style='padding:10px'>");
								if(specialColumnType==1){
								  sb.append("<input id='saveBtn2' type='button'  value='编辑附件' onclick=\"changguiEditFile1()\" class='form_bt_orange'/> &nbsp;\r\n");
								}
								sb.append("<table id=\"gridTableSample\"></table>");
								sb.append("<div id=\"gridPagerSample\"></div>");
								sb.append("</div>");
								sb.append("<div title='检测项目' style='padding:10px'>");
								if(specialColumnType==1){
								  sb.append("<input id='saveBtn2' type='button'  value='编辑附件' onclick=\"changguiEditFile2()\" class='form_bt_orange'/> &nbsp;\r\n");
								}
								sb.append("<table id=\"gridTableItem1\"></table>");
								sb.append("<div id=\"gridPagerItem1\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
							}else if("2".equals(specialColumn)){
								String deptid = getDeptid();
//								tableuser = FormHandler.getUserTable(String.valueOf(flowTask.getMainId()),deptid,String.valueOf(flowTask.getDeptSeq()));
//								functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),deptid);
//								getRequest().setAttribute("functionuser", functionuser);
//								getRequest().setAttribute("tableuser", tableuser);
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								
								sb.append("<table style=\"width: 100%;\">"); 
								sb.append("<tr>");
								sb.append("<td align='center'>"); 
								sb.append("<table width='100%' id=\"gridTableUser\"></table>");
								sb.append("<div id=\"gridPagerUser\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
								
								sb.append("<tr>");
								sb.append("<td align='right'>"); 
								sb.append("选择用户：");
								sb.append("</td>");
								sb.append("<td>");
								sb.append("<select class='fselect' id='fuserId' name='fuserId'></select>");
								sb.append("<input type='button' value='分配' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
								sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
								sb.append("</td>");
								sb.append("<td></td>");
								sb.append("<td></td>");
								sb.append("</tr>");
							}else if("3".equals(specialColumn)){//选择原始记录
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								
								getRequest().setAttribute("tablejs", tablejs);
//                                functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid());
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								if("1".equals(specialType)){//编辑
									sb.append("<input type='button' value='原始记录' onclick=\"openYsjl('0')\" class='form_bt_orange' style='width:120px;'/>");
								}else{//查看
									sb.append("<input type='button' value='原始记录单校对' onclick=\"viewYsjl('0')\" class='form_bt_orange' style='width:120px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								
								
								
								
								 
							}else if("4".equals(specialColumn)){//选择报告
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('hideCol','T_JIANCEYUANNAME');";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_BGFILEPATH');";
								
								getRequest().setAttribute("tablejs", tablejs);
//                                functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid());
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								sb.append("<input type='button' value='查看原始记录' onclick=\"openYsjl('1')\" class='form_bt_orange' style='width:120px;'/>");
								
								if("1".equals(specialType)){//编辑
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='制作报告' onclick=\"openBg('0')\" class='form_bt_orange' style='width:100px;'/>");
								}else{//查看
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='查看报告' onclick=\"openBg('1')\" class='form_bt_orange' style='width:100px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								 
							}
							else if("5".equals(specialColumn)){//样品/检测项目列表
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    getRequest().setAttribute("tablejs", tablejs);

//							    functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid());
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								
								if(specialColumnType==1){
									sb.append("<tr>");
									sb.append("<td align='right'>"); 
									sb.append("选择用户：");
									sb.append("</td>");
									sb.append("<td>");
									sb.append("<select class='fselect' id='fuserId' name='fuserId' )\"></select>");
									sb.append("<input type='button' value='分配' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
									sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
									sb.append("</td>");
									sb.append("<td></td>");
									sb.append("<td></td>");
									sb.append("</tr>");
								}
							}
							if (steps!=null)
							{
								String isshow = "";
								if (steps.size()<=1)
								{
									isshow = "none";
								}
								if(2844==formnew1.getId()||2845==formnew1.getId()||2846==formnew1.getId()){
									sb.append("</tr>");
								}else{
									sb.append("<tr style='display:"+isshow+";'><td style='text-align:right;'>下一步骤：</td><td>");
									int i = 0;
									for(Iterator iter = steps.iterator();iter.hasNext();)
									{
										StepEntity entity = (StepEntity)iter.next();
										if (i==0){
											sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' checked style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
										}
										else{
											sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
										}
										i++;
									}
									sb.append("</td>");
									
									sb.append("</tr>");
								}
								
							}
						}else if("2".equals(formColumn)){//如果是两列显示
							if (steps!=null)
							{
								sb.append("<tr><td style='text-align:right;width:120px;'>流程名称：</td><td colspan='3'><input type='text' id='flowname' name='flowname' value='"+flowTask.getFlowName()+"' style='border: 1px solid #999;padding: 5px;width:705px' readonly ='readonly' ></td>");
							}
							int j = 1;
							
							for (int i = 0; i < fieldList.size(); i++) {
								AutoFormsField field1 = fieldList.get(i);
								objs = values[i];
								if(formnew1.getColumnForigen() != null && field1.getFieldName().toLowerCase().equals(formnew1.getColumnForigen().toLowerCase())){//外键的值
									tablejsid = String.valueOf(objs);
								}
								if(!field1.getFieldName().equals("ID")){//除了ID的添加
									//页面是否显示
									if("0".equals(field1.getIsPageShow().toString())){
										//columnHidden += "<input type='hidden' id=\""+field1.getFieldName()+"\" name=\""+field1.getFieldName()+"\" value=\""+objs+"\"  />";
										continue;
									}
									//============================= 查询具体某个字段的值 END =============================
									if(j%2==1){
										sb.append("<tr>");
									}
									columns += field1.getFieldName() + ",";
									sb.append("<td align=\"right\">"+field1.getCnName()+"：</td>");
									sb.append("<td align=\"left\">");
									sb.append(getUpdateHtml(field1, objs, String.valueOf(flowTask.getMainId())));
									sb.append("</td>");
									if(j%2==0){
										sb.append("</tr>");
									}
									j++;
								}
								if(!StringUtil.isEmpty(field1.getEventFunction())){
									bodyjs.append(field1.getEventFunction());
								}
							}
							//列表展示
							String columnName = formnew1.getColumnCnName();
							String columnSql = formnew1.getColumnSql();
							String columnForigen = formnew1.getColumnForigen();
							if(!StringUtil.isEmpty(columnName) && !StringUtil.isEmpty(columnSql)){
								if("flow_task_id".equals(columnForigen.toLowerCase())){//如果外键是流程id
									tablejsid = String.valueOf(flowTask.getId());
								}
								String tablenum = String.valueOf(0);
								tablejs += FormHandler.getTableJS(String.valueOf(formnew1.getId()),tablenum, columnName,columnSql,formnew1.getColumnWidth(),tablejsid,flowstateid);
								getRequest().setAttribute("tablejs", tablejs);
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<table style=\"width: 100%;\">"); 
								sb.append("<tr>");
								sb.append("<td>"); 
								sb.append("<table  width='100%' id=\"gridTable"+tablenum+"\"></table>");
								sb.append("<div id=\"gridPager"+tablenum+"\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
							}
							//选择部门
							String specialColumn = formnew1.getSpecialColumn();
							String specialType = formnew1.getSpecialType()!=null?formnew1.getSpecialType().toString():"";
							Long specialColumnType = formnew1.getSpecialType();
							if("1".equals(specialColumn)){//项目列表
								//样品列表
								tablejs += FormHandler.getSampleTable(String.valueOf(flowTask.getId()));
								//检测项目列表
								tablejs += FormHandler.getItemeTable(String.valueOf(flowTask.getId()),"",String.valueOf(specialType));
							
								if(specialColumnType==2){
									tablejs +="jQuery(\"#gridTableSample\").jqGrid('hideCol','T_SAMPLENO');";
								}
							    getRequest().setAttribute("tablejs", tablejs);
								//样品/检测项目 多tab页
								if("1".equals(specialColumn)){
									sb.append("<tr>");
									sb.append("<td colspan='4' align='center'>"); 
									sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
									sb.append("<div title='样       品' style='padding:10px'>");
									if(specialColumnType==1){
									  sb.append("<input id='saveBtn2' type='button'  value='编辑附件' onclick=\"changguiEditFile1()\" class='form_bt_orange'/> &nbsp;\r\n");
									}
									sb.append("<table id=\"gridTableSample\"></table>");
									sb.append("<div id=\"gridPagerSample\"></div>");
									sb.append("</div>");
									sb.append("<div title='检测项目' style='padding:10px'>");
									if(specialColumnType==1){
									  sb.append("<input id='saveBtn2' type='button'  value='编辑附件' onclick=\"changguiEditFile2()\"  class='form_bt_orange'/> &nbsp;\r\n");
									}
									sb.append("<table id=\"gridTableItem1\"></table>");
									sb.append("<div id=\"gridPagerItem1\"></div>");
									sb.append("</div>");
									sb.append("</div>");
								    sb.append("</td>");
									sb.append("</tr>");
								}
							}else if("2".equals(specialColumn)){
								String deptid = getDeptid();
					//			tableuser = FormHandler.getUserTable(String.valueOf(flowTask.getMainId()),deptid,String.valueOf(flowTask.getDeptSeq()));
								functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),deptid,flowtaskinfoid);
								getRequest().setAttribute("functionuser", functionuser);
								getRequest().setAttribute("tableuser", tableuser);
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								
								sb.append("<table style=\"width: 100%;\">"); 
								sb.append("<tr>");
								sb.append("<td align='center'>"); 
								sb.append("<table width='100%' id=\"gridTableUser\"></table>");
								sb.append("<div id=\"gridPagerUser\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
								
								sb.append("<tr>");
								sb.append("<td align='right'>"); 
								sb.append("选择用户：");
								sb.append("</td>");
								sb.append("<td>");
								sb.append("<select class='fselect' id='fuserId' name='fuserId'></select>");
								sb.append("<input type='button' value='分配' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
								sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
								sb.append("</td>");
								sb.append("<td></td>");
								sb.append("<td></td>");
								sb.append("</tr>");
							}else if("3".equals(specialColumn)){//选择原始记录
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								
								getRequest().setAttribute("tablejs", tablejs);
//                                functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid());
//								
//							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								if("1".equals(specialType)){//编辑
									sb.append("<input type='button' value='原始记录' onclick=\"openYsjl('0')\" class='form_bt_orange' style='width:120px;'/>");
								}else{//查看
									sb.append("<input type='button' value='原始记录单校对' onclick=\"viewYsjl('0')\" class='form_bt_orange' style='width:120px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								
							
								
								 
							}else if("4".equals(specialColumn)){//选择报告
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('hideCol','T_JIANCEYUANNAME');";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_BGFILEPATH');";
								
								getRequest().setAttribute("tablejs", tablejs);
//                                functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid());
//								
//							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								sb.append("<input type='button' value='查看原始记录' onclick=\"openYsjl('1')\" class='form_bt_orange' style='width:120px;'/>");
								
								if("1".equals(specialType)){//编辑
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='制作报告' onclick=\"openBg('0')\" class='form_bt_orange' style='width:100px;'/>");
								}else{//查看
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='查看报告' onclick=\"openBg('1')\" class='form_bt_orange' style='width:100px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								
							}
							else if("5".equals(specialColumn)){//样品/检测项目列表
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    getRequest().setAttribute("tablejs", tablejs);

//							    functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid());
//								
//							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								
								if(specialColumnType==1){
									sb.append("<tr>");
									sb.append("<td align='right'>"); 
									sb.append("选择用户：");
									sb.append("</td>");
									sb.append("<td>");
									sb.append("<select class='fselect' id='fuserId' name='fuserId' )\"></select>");
									sb.append("<input type='button' value='分配' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
									sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
									sb.append("</td>");
									sb.append("<td></td>");
									sb.append("<td></td>");
									sb.append("</tr>");
								}
							}
							if (steps!=null)
							{
								//sb.append("<tr><td style='text-align:right;width:120px;'>流程名称：</td><td><input type='text' id='flowname' name='flowname' value='"+flowTask.getFlowName()+"'></td>");
								String isshow = "";
								if (steps.size()<=1)
								{
									isshow = "none";
								}
								
								if(2844==formnew1.getId()||2845==formnew1.getId()||2846==formnew1.getId()){
									sb.append("</tr>");
								}else{
									sb.append("<tr style='display:"+isshow+";'><td style='text-align:right;'>下一步骤：</td><td>");
									int i = 0;
									for(Iterator iter = steps.iterator();iter.hasNext();)
									{
										StepEntity entity = (StepEntity)iter.next();
										if (i==0){
											sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' checked style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
										}
										else{
											sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
										}
										i++;
									}
									sb.append("</td>");
									
									sb.append("</tr>");
								}
							}
						}
						sb.append("<table width='100%' border='0' align='center' class='formTableNew'>\r\n");
						sb.append("<td align='center' >\r\n");
						
						/**********************************按钮生成 列表　START***************************************/
						String buttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type,t.fitter_condition from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 1 ";
						List buttonList = autoService.getDatabySql(buttonSql);
						if(buttonList != null && buttonList.size() != 0 ){
							for (int j = 0; j < buttonList.size(); j++) {
								Object[] obj = (Object[])buttonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"buttonOnclick("+obj[1]+",'"+obj[0]+"','"+obj[2]+"','"+obj[3]+"','"+obj[4]+"')\"/>\r\n");
							}
						}
						/**********************************按钮生成　END***************************************/
						/**********************************生成原始记录按钮　START***************************************/
						String ysjlSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 2 ";
						List ysjlList = autoService.getDatabySql(ysjlSql);
						if(ysjlList != null && ysjlList.size() != 0 ){
							for (int j = 0; j < ysjlList.size(); j++) {
								Object[] obj = (Object[])ysjlList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openYsjl("+obj[3]+")\"/>\r\n");
							}
						}
						/**********************************生成原始记录按钮　END***************************************/
						/**********************************生成军检原始记录按钮　START***************************************/
						String jjysjlSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 5 ";
						List jjysjlList = autoService.getDatabySql(jjysjlSql);
						if(jjysjlList != null && jjysjlList.size() != 0 ){
							for (int j = 0; j < jjysjlList.size(); j++) {
								Object[] obj = (Object[])jjysjlList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openjjYsjl("+obj[3]+")\"/>\r\n");
							}
						}
						/**********************************生成军检原始记录按钮　END***************************************/
						/**********************************生成合格证按钮　START***************************************/
						String hgzSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 3 ";
						List hgzList = autoService.getDatabySql(hgzSql);
						if(hgzList != null && hgzList.size() != 0 ){
							for (int j = 0; j < hgzList.size(); j++) {
								Object[] obj = (Object[])hgzList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openHgz("+obj[3]+")\"/>\r\n");
							}
						}
						/**********************************生成合格证按钮　END***************************************/
						
						/**********************************生成其他按钮 编辑　START***************************************/
						String otherSql = " select t.id, t.button_name,t.mode_path,t.choose_form_id from print_report_mode t where t.choose_form_id = "+formid;
						List otherList = autoService.getDatabySql(otherSql);
						if(otherList != null && otherList.size() != 0 ){
							for (int j = 0; j < otherList.size(); j++) {
								Object[] obj = (Object[])otherList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[1]+"\" onclick=\"viewOtherForm('"+obj[2]+"','"+obj[0]+"','"+obj[3]+"')\"/>\r\n");
							}
						}
						/**********************************生成其他按钮　END***************************************/
						
						/**********************************生成其他按钮 查看　START***************************************/
						String otherLook = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 4 ";
						List otherLookList = autoService.getDatabySql(otherLook);
						if(otherLookList != null && otherLookList.size() != 0 ){
							for (int j = 0; j < otherLookList.size(); j++) {
								Object[] obj = (Object[])otherLookList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openOtherLook('"+obj[3]+"','"+obj[1]+"')\"/>\r\n");
							}
						}
						/**********************************生成其他按钮　END***************************************/
						
						/**********************************选择设备　START***************************************/
						String sheBeibuttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 6 ";
						List sheBeiButtonList = autoService.getDatabySql(sheBeibuttonSql);
						if(sheBeiButtonList != null && sheBeiButtonList.size() != 0 ){
							for (int j = 0; j < sheBeiButtonList.size(); j++) {
								Object[] obj = (Object[])sheBeiButtonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" value=\""+obj[0]+"\" onclick=\"chooseEquipment("+obj[1]+",'"+obj[0]+"','"+obj[2]+"','"+obj[3]+"')\"/>\r\n");
							}
						}
						/**********************************选择设备　END***************************************/
						/**********************************自动确认样品　START***************************************/
						String ziDongbuttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 8 ";
						List ziDongButtonList = autoService.getDatabySql(ziDongbuttonSql);
						if(ziDongButtonList != null && ziDongButtonList.size() != 0 ){
							for (int j = 0; j < ziDongButtonList.size(); j++) {
								Object[] obj = (Object[])ziDongButtonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" value=\""+obj[0]+"\" style=\"width:120px;\" onclick=\"ziDongQueRen("+obj[1]+",'"+obj[0]+"','"+obj[2]+"','"+obj[3]+"')\"/>\r\n");
							}
						}
						/**********************************自动确认样品　END***************************************/
						
						/**********************************查看施工单　START***************************************/
						String sgdbuttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 9 ";
						List sgdButtonList = autoService.getDatabySql(sgdbuttonSql);
						if(sgdButtonList != null && sgdButtonList.size() != 0 ){
							for (int j = 0; j < sgdButtonList.size(); j++) {
								Object[] obj = (Object[])sgdButtonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" value=\""+obj[0]+"\" style=\"width:120px;\" onclick=\"viewshigongdan()\"/>\r\n");
							}
						}
						/**********************************查看施工单　END***************************************/
						
						/**********************************项目分配　START***************************************/
						String xiangMubuttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 7 ";
						List xiangMuButtonList = autoService.getDatabySql(xiangMubuttonSql);
						if(xiangMuButtonList != null && xiangMuButtonList.size() != 0 ){
							for (int j = 0; j < xiangMuButtonList.size(); j++) {
								Object[] obj = (Object[])xiangMuButtonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" value=\""+obj[0]+"\" onclick=\"chooseProject("+obj[1]+",'"+obj[0]+"','"+obj[2]+"','"+obj[3]+"')\"/>\r\n");
							}
						}
						/**********************************项目分配　END***************************************/
						if("proc5".equals(stateid)){
						  sb.append("<input id='queryhuizongbg' type='button'  value='查看报告' class='form_bt_orange' onclick=\"editHuizongbg('1')\"/>\r\n");
						}
						if("gcjd".equals(stateid)){
							sb.append("<input id='deletemodel' type='button'  value='删除' class='form_bt_orange' onclick=\"deleteModel()\"/>\r\n");
						    sb.append("<input id='choosemodel' type='button'  value='选择模版' class='form_bt_orange' onclick=\"chooseModel()\"/>\r\n");
						}
						if(!"gcjd".equals(stateid)){
						    sb.append("<input id='saveupdateBtn' type='button'  value='保 存' class='form_bt_orange' />\r\n");
						}
						sb.append("<input id='saveBtn' type='button'  value='提 交' class='form_bt_orange' />\r\n");
						sb.append("<input type='button' id='closeBtn' value='取 消' class='form_bt_grey' />\r\n");
						sb.append("</td>\r\n");
						sb.append("</table>\r\n");
						sb.append(columnHidden);
					}else{ 
						if(null != formnew1 && null!= formnew1.getFormColumn()){
							String formColumn = String.valueOf(formnew1.getFormColumn());
							sb.append("<div title='"+formnew1.getFormCnName()+"' style='padding:20px;'>\r\n");
							sb.append("<table width='100%' border='0' align='center' class='formTableNew'>\r\n");
							if("1".equals(formColumn) || formnew1.getFormColumn()==null){//如果是一列显示
								for (int i = 0; i < fieldList.size(); i++) {
									AutoFormsField field = fieldList.get(i);
									objs = values[i];
									if(formnew1.getColumnForigen() != null && field.getFieldName().toLowerCase().equals(formnew1.getColumnForigen().toLowerCase())){//外键的值
										tablejsid = String.valueOf(objs);
									}
									//页面是否显示
									if("0".equals(field.getIsPageShow().toString())){
										//columnHidden += "<input type='hidden' id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+objs+"\"  />";
										continue;
									}
									
									if(!field.getFieldName().equals("ID")){//除了ID的添加
										//columns += field.getFieldName() + ",";
										sb.append("<tr>");
										sb.append("<td align=\"right\">"+field.getCnName()+"：</td>");
										sb.append("<td align=\"left\">");
										sb.append(getUpdateHtmlNoIdAndName(field,objs==null?"":objs.toString()));
										sb.append("</td>");
										sb.append("</tr>");
									}
									if(!StringUtil.isEmpty(field.getEventFunction())){
										bodyjs.append(field.getEventFunction());
									}
								}
								//列表展示
								String columnName = formnew1.getColumnCnName();
								String columnSql = formnew1.getColumnSql();
								String otherColumnSql = formnew1.getOtherColumnSql();//其他sql
								if(!StringUtil.isEmpty(otherColumnSql)){
									columnSql = otherColumnSql;
								}
								String columnForigen = formnew1.getColumnForigen();
								if(!StringUtil.isEmpty(columnName) && !StringUtil.isEmpty(columnSql)){
									if("flow_task_id".equals(columnForigen.toLowerCase())){//如果外键是流程id
										tablejsid = String.valueOf(flowTask.getId());
									}
									String tablenum = String.valueOf(0);
									tablejs += FormHandler.getTableJS(String.valueOf(formnew1.getId()),tablenum, columnName,columnSql,formnew1.getColumnWidth(),tablejsid,flowstateid);
									getRequest().setAttribute("tablejs", tablejs);
									sb.append("<tr>");
									sb.append("<td colspan='2' align='center'>"); 
									sb.append("<table style=\"width: 90%;\" class=\"tableCont\">"); 
									sb.append("<tr>");
									sb.append("<td>"); 
									sb.append("<table id=\"gridTable"+tablenum+"\"></table>");
									sb.append("<div id=\"gridPager"+tablenum+"\"></div>");
									sb.append("</td>");
									sb.append("</tr>");
									sb.append("</table>");
									sb.append("</td>");
									sb.append("</tr>");
								}
								//选择部门
								String specialColumn = formnew1.getSpecialColumn();
								String specialType = formnew1.getSpecialType()!=null?formnew1.getSpecialType().toString():"";
								if("1".equals(specialColumn)){//项目列表
									tabledept = FormHandler.getDeptTable(String.valueOf(flowTask.getMainId()));
									functionjs = FormHandler.getJsFunction(String.valueOf(flowTask.getMainId()));
									getRequest().setAttribute("tabledept", tabledept);
									getRequest().setAttribute("functionjs", functionjs);
									sb.append("<tr>");
									sb.append("<td colspan='4' align='center'>"); 
									
									sb.append("<table style=\"width: 100%;\">"); 
									sb.append("<tr>");
									sb.append("<td colspan='4'  align='center'>"); 
									sb.append("<table width='100%' id=\"gridTableDept\"></table>");
									sb.append("<div id=\"gridPagerDept\"></div>");
									sb.append("</td>");
									sb.append("</tr>");
									sb.append("</table>");
									sb.append("</td>");
									sb.append("</tr>");
									
									sb.append("<tr>");
									sb.append("<td align='right'>"); 
									sb.append("选择部门：");
									sb.append("</td>");
									sb.append("<td>");
									sb.append("<input type=\"hidden\" id=\"orgId\" name=\"orgId\"  value=\"\"/>"); 
									sb.append("<input id=\"citySel\" name=\"orgNameLabel\" type=\"text\"  value=\"\" readonly style=\"width:252px; height:18px; border:1px #7f9db9 solid; background:url(img/xia_l.jpg) no-repeat right center;\" onclick=\"showMenu();\" />"); 
									sb.append("<div id=\"menuContent\" class=\"menuContent\" style=\"display:none; position: absolute;\">"); 
									sb.append("<ul id=\"treeDemo\" class=\"ztree\" style=\"margin-top:0; width:244px; height: 240px;\"></ul>"); 
									sb.append("</div> ");
									//sb.append("<input type='button' value='手动分配' onclick=\"fenpeiItem()\" class='form_bt_orange' />&nbsp;<input type='button' value='自动分配' onclick=\"fenpeiZiDongItem()\" class='form_bt_orange' />");
									sb.append("<input type='button' value='手动分配' onclick=\"fenpeiItem()\" class='form_bt_orange' />&nbsp;<input type='button' value='值班人' onclick=\"zhiBanRen()\" class='form_bt_orange' />");
									sb.append("</td>");
									//sb.append("<td></td>");
									sb.append("<td></td>");
									sb.append("</tr>");
								}else if("2".equals(specialColumn)){
									String deptid = getDeptid();
						//			tableuser = FormHandler.getUserTable(String.valueOf(flowTask.getMainId()),deptid,String.valueOf(flowTask.getDeptSeq()));
									functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),deptid,flowtaskinfoid);
									getRequest().setAttribute("functionuser", functionuser);
						//			getRequest().setAttribute("tableuser", tableuser);
									sb.append("<tr>");
									sb.append("<td colspan='4' align='center'>"); 
									
									sb.append("<table style=\"width: 100%;\">"); 
									sb.append("<tr>");
									sb.append("<td align='center'>"); 
									sb.append("<table width='100%' id=\"gridTableUser\"></table>");
									sb.append("<div id=\"gridPagerUser\"></div>");
									sb.append("</td>");
									sb.append("</tr>");
									sb.append("</table>");
									sb.append("</td>");
									sb.append("</tr>");
									
									sb.append("<tr>");
									sb.append("<td align='right'>"); 
									sb.append("选择用户：");
									sb.append("</td>");
									sb.append("<td>");
									sb.append("<select class='fselect' id='fuserId' name='fuserId'></select>");
									sb.append("<input type='button' value='分配' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
									sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
									sb.append("</td>");
									sb.append("<td></td>");
									sb.append("<td></td>");
									sb.append("</tr>");
								}else if("3".equals(specialColumn)){//选择原始记录
									String deptid = getDeptid();
									
									
									if("1".equals(specialType)){//编辑
										sb.append("<tr>");
										sb.append("<td  colspan='4'>"); 
						//				tableYsjl = FormHandler.getYsjlTable(String.valueOf(flowTask.getMainId()),deptid,flowTask.getUserSeq(),"");
										functionYsjl = FormHandler.getYsjlJsFunction(String.valueOf(flowTask.getMainId()),deptid);
										getRequest().setAttribute("functionYsjl", functionYsjl);
						//				getRequest().setAttribute("tableYsjl", tableYsjl);
										sb.append("<input type='button' value='原始记录单录入' onclick=\"openYsjl('0')\" class='form_bt_orange' style='width:120px;margin-left:60px'/>");
										sb.append("<input type='button' value='删除' onclick=\"deleteYsjl()\" class='form_bt_orange' style='width:80px;margin-left:10px'/>");
										sb.append("</td>");
										sb.append("</tr>");
										
										sb.append("<tr>");
										sb.append("<td colspan='4' align='center'>"); 
										
										sb.append("<table style=\"width: 100%;\">"); 
										sb.append("<tr>");
										sb.append("<td align='center'>"); 
										sb.append("<table width='100%' id=\"gridTableYsjl\"></table>");
										sb.append("<div id=\"gridPagerYsjl\"></div>");
										sb.append("</td>");
										sb.append("</tr>");
										sb.append("</table>");
										sb.append("</td>");
										sb.append("</tr>");
									}else{//查看
										sb.append("<tr>");
										sb.append("<td  colspan='4'>"); 
							//			tableYsjl1 = FormHandler.getYsjlTable1(String.valueOf(flowTask.getMainId()),deptid,flowTask.getUserSeq(),"");
										functionYsjl1 = FormHandler.getYsjlJsFunction(String.valueOf(flowTask.getMainId()),deptid);
										getRequest().setAttribute("functionYsjl1", functionYsjl1);
						   //			etRequest().setAttribute("tableYsjl1", tableYsjl1);
										sb.append("<input type='button' value='原始记录单校对' onclick=\"viewYsjl('0')\" class='form_bt_orange' style='width:120px;margin-left:60px'/>");
										sb.append("</td>");
										sb.append("</tr>");
										
										sb.append("<tr>");
										sb.append("<td colspan='4' align='center'>"); 
										
										sb.append("<table style=\"width: 100%;\">"); 
										sb.append("<tr>");
										sb.append("<td align='center'>"); 
										sb.append("<table width='100%' id=\"gridTableYsjl\"></table>");
										sb.append("<div id=\"gridPagerYsjl1\"></div>");
										sb.append("</td>");
										sb.append("</tr>");
										sb.append("</table>");
										sb.append("</td>");
										sb.append("</tr>");
									}
								}else if("4".equals(specialColumn)){//选择报告
									String deptid = getDeptid();
									
									
									if("1".equals(specialType)){//编辑
										sb.append("<tr>");
										sb.append("<td  colspan='4'>"); 
										String tablenum = String.valueOf(0);
							//			tableBg = FormHandler.getBgTable(String.valueOf(flowTask.getMainId()),tablenum,deptid,flowTask.getUserSeq(),flowTask.getId(),flowstate1.getStateid(),"");
										//functionBg = FormHandler.getBgJsFunction(String.valueOf(flowTask.getMainId()),deptid);
										getRequest().setAttribute("functionBg", functionBg);
							//			getRequest().setAttribute("tableBg", tableBg);
										sb.append("<input type='button' value='查看原始记录单' onclick=\"viewYsjl('1',"+tablenum+")\" class='form_bt_orange' style='width:120px;margin-left:60px'/>");
										sb.append("<input type='button' value='制作报告' onclick=\"openBg('0',"+tablenum+")\" class='form_bt_orange' style='width:100px;margin-left:60px'/>");
										sb.append("<input type='button' value='删除' onclick=\"deleteBg()\" class='form_bt_orange' style='width:80px;margin-left:10px'/>");
										sb.append("</td>");
										sb.append("</tr>");
										
										sb.append("<tr>");
										sb.append("<td colspan='4' align='center'>"); 
										
										sb.append("<table style=\"width: 100%;\">"); 
										sb.append("<tr>");
										sb.append("<td align='center'>"); 
										sb.append("<table width='100%' id=\"gridTableBg"+tablenum+"\"></table>");
										sb.append("<div id=\"gridPagerBg"+tablenum+"\"></div>");
										sb.append("</td>");
										sb.append("</tr>");
										sb.append("</table>");
										sb.append("</td>");
										sb.append("</tr>");
									}else{//查看
										sb.append("<tr>");
										sb.append("<td  colspan='4'>");
										String tablenum = String.valueOf(0);
							//			tableBg1 += FormHandler.getBgTable1(String.valueOf(flowTask.getMainId()),tablenum,deptid,flowTask.getUserSeq(),formid,flowTask.getId(),flowstate1.getStateid(),"");
										//functionBg1 = FormHandler.getBgJsFunction(String.valueOf(flowTask.getMainId()),deptid);
										getRequest().setAttribute("functionBg1", functionBg1);
							//			getRequest().setAttribute("tableBg1", tableBg1);
										sb.append("<input type='button' value='查看报告' onclick=\"openBg('1',1"+tablenum+")\" class='form_bt_orange' style='width:100px;margin-left:60px'/>");
										sb.append("<input type='button' value='查看原始记录单' onclick=\"viewYsjl('0')\" class='form_bt_orange' style='width:120px;margin-left:60px'/>");
										
										sb.append("</td>");
										sb.append("</tr>");
										
										sb.append("<tr>");
										sb.append("<td colspan='4' align='center'>"); 
										
										sb.append("<table style=\"width: 100%;\">"); 
										sb.append("<tr>");
										sb.append("<td align='center'>"); 
										sb.append("<table width='100%' id=\"gridTableBg1"+tablenum+"\"></table>");
										sb.append("<div id=\"gridPagerBg1"+tablenum+"\"></div>");
										sb.append("</td>");
										sb.append("</tr>");
										sb.append("</table>");
										sb.append("</td>");
										sb.append("</tr>");
									}
									
									
									
									 
								}
							}else if("2".equals(formColumn)){//如果是两列显示
								int j = 1;
								for (int i = 0; i < fieldList.size(); i++) {
									AutoFormsField field1 = fieldList.get(i);
									objs = values[i];
									if(formnew1.getColumnForigen() != null && field1.getFieldName().toLowerCase().equals(formnew1.getColumnForigen().toLowerCase())){//外键的值
										tablejsid = String.valueOf(objs);
									}
									//页面是否显示
									if("0".equals(field1.getIsPageShow().toString())){
										//columnHidden += "<input type='hidden' id=\""+field1.getFieldName()+"\" name=\""+field1.getFieldName()+"\" value=\""+objs+"\"  />";
										continue;
									}
									
									if(!field1.getFieldName().equals("ID")){//除了ID的添加
										if(j%2==1){
											sb.append("<tr>");
										}
										//columns += field1.getFieldName() + ",";
										sb.append("<td align=\"right\">"+field1.getCnName()+"：</td>");
										sb.append("<td align=\"left\">");
										sb.append(getUpdateHtmlNoIdAndName(field1,objs));
										sb.append("</td>");
										if(j%2==0){
											sb.append("</tr>");
										}
										j++;
									}
									if(!StringUtil.isEmpty(field1.getEventFunction())){
										bodyjs.append(field1.getEventFunction());
									}
								} 
								//列表展示
								String columnName = formnew1.getColumnCnName();
								String columnSql = formnew1.getColumnSql();
								String otherColumnSql = formnew1.getOtherColumnSql();//其他sql
								if(!StringUtil.isEmpty(otherColumnSql)){
									columnSql = otherColumnSql;
								}
								String columnForigen = formnew1.getColumnForigen();
								if(!StringUtil.isEmpty(columnName) && !StringUtil.isEmpty(columnSql)){
									if("flow_task_id".equals(columnForigen.toLowerCase())){//如果外键是流程id
										tablejsid = String.valueOf(flowTask.getId());
									}
									String tablenum = String.valueOf(0);
									tablejs += FormHandler.getTableJS(String.valueOf(formnew1.getId()),tablenum, columnName,columnSql,formnew1.getColumnWidth(),tablejsid,flowstateid);
									getRequest().setAttribute("tablejs", tablejs);
									sb.append("<tr>");
									sb.append("<td colspan='4' align='center'>"); 
									sb.append("<table style=\"width: 90%;\" class=\"tableCont\">"); 
									sb.append("<tr>");
									sb.append("<td colspan='4'  align=center>"); 
									sb.append("<table id=\"gridTable"+tablenum+"\"></table>");
									sb.append("<div id=\"gridPager"+tablenum+"\"></div>");
									sb.append("</td>");
									sb.append("</tr>");
									sb.append("</table>");
									sb.append("</td>");
									sb.append("</tr>");
								}
								//选择部门
								String specialColumn = formnew1.getSpecialColumn();
								String specialType = formnew1.getSpecialType()!=null?formnew1.getSpecialType().toString():"";
								if("1".equals(specialColumn)){//项目列表
									tabledept = FormHandler.getDeptTable(String.valueOf(flowTask.getMainId()));
									functionjs = FormHandler.getJsFunction(String.valueOf(flowTask.getMainId()));
									getRequest().setAttribute("tabledept", tabledept);
									getRequest().setAttribute("functionjs", functionjs);
									sb.append("<tr>");
									sb.append("<td colspan='4' align='center'>"); 
									
									sb.append("<table style=\"width: 100%;\">"); 
									sb.append("<tr>");
									sb.append("<td colspan='4'  align='center'>"); 
									sb.append("<table width='100%' id=\"gridTableDept\"></table>");
									sb.append("<div id=\"gridPagerDept\"></div>");
									
									
									sb.append("</td>");
									sb.append("</tr>");
									sb.append("</table>");
									sb.append("</td>");
									sb.append("</tr>");
									
									sb.append("<tr>");
									sb.append("<td align='right'>"); 
									sb.append("选择部门：");
									sb.append("</td>");
									sb.append("<td>");
									sb.append("<input type=\"hidden\" id=\"orgId\" name=\"orgId\"  value=\"\"/>"); 
									sb.append("<input id=\"citySel\" name=\"orgNameLabel\" type=\"text\"  value=\"\" readonly style=\"width:252px; height:18px; border:1px #7f9db9 solid; background:url(img/xia_l.jpg) no-repeat right center;\" onclick=\"showMenu();\" />"); 
									sb.append("<div id=\"menuContent\" class=\"menuContent\" style=\"display:none; position: absolute;\">"); 
									sb.append("<ul id=\"treeDemo\" class=\"ztree\" style=\"margin-top:0; width:244px; height: 240px;\"></ul>"); 
									sb.append("</div> ");
									//sb.append("<input type='button' value='手动分配' onclick=\"fenpeiItem()\" class='form_bt_orange' />&nbsp;<input type='button' value='自动分配' onclick=\"fenpeiZiDongItem()\" class='form_bt_orange' />");
									sb.append("<input type='button' value='手动分配' onclick=\"fenpeiItem()\" class='form_bt_orange' />&nbsp;<input type='button' value='值班人' onclick=\"zhiBanRen()\" class='form_bt_orange' />");
									sb.append("</td>");
									//sb.append("<td></td>");
									sb.append("<td></td>");
									sb.append("</tr>");
								}else if("2".equals(specialColumn)){
									String deptid = getDeptid();
						//			tableuser = FormHandler.getUserTable(String.valueOf(flowTask.getMainId()),deptid,String.valueOf(flowTask.getDeptSeq()));
									functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),deptid,flowtaskinfoid);
									getRequest().setAttribute("functionuser", functionuser);
						//			getRequest().setAttribute("tableuser", tableuser);
									sb.append("<tr>");
									sb.append("<td colspan='4' align='center'>"); 
									
									sb.append("<table style=\"width: 100%;\">"); 
									sb.append("<tr>");
									sb.append("<td colspan='4'  align='center'>"); 
									sb.append("<table width='100%' id=\"gridTableUser\"></table>");
									sb.append("<div id=\"gridPagerUser\"></div>");
									sb.append("</td>");
									sb.append("</tr>");
									sb.append("</table>");
									sb.append("</td>");
									sb.append("</tr>");
									
									sb.append("<tr>");
									sb.append("<td align='right'>"); 
									sb.append("选择用户：");
									sb.append("</td>");
									sb.append("<td>");
									sb.append("<select class='fselect' id='fuserId' name='fuserId'></select>");
									sb.append("<input type='button' value='分配' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
									sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
									sb.append("</td>");
									sb.append("<td></td>");
									sb.append("<td></td>");
									sb.append("</tr>");
								}else if("3".equals(specialColumn)){//选择原始记录
									String deptid = getDeptid();
									
									
									if("1".equals(specialType)){//编辑
										sb.append("<tr>");
										sb.append("<td  colspan='4'>"); 
										functionYsjl = FormHandler.getYsjlJsFunction(String.valueOf(flowTask.getMainId()),deptid);
										getRequest().setAttribute("functionYsjl", functionYsjl);
										sb.append("<input type='button' value='原始记录单校对' onclick=\"openYsjl('1')\" class='form_bt_orange' style='width:120px;margin-left:60px'/>");
								//		sb.append("<input type='button' value='删除' onclick=\"deleteYsjl()\" class='form_bt_orange' style='width:80px;margin-left:10px'/>");
										sb.append("</td>");
										sb.append("</tr>");
										
										sb.append("<tr>");
										sb.append("<td colspan='4' align='center'>"); 
										
										sb.append("<table style=\"width: 100%;\">"); 
										sb.append("<tr>");
										sb.append("<td align='center'>"); 
										sb.append("<table width='100%' id=\"gridTableYsjl\"></table>");
										sb.append("<div id=\"gridPagerYsjl\"></div>");
										sb.append("</td>");
										sb.append("</tr>");
										sb.append("</table>");
										sb.append("</td>");
										sb.append("</tr>");
									}else{//查看
										sb.append("<tr>");
										sb.append("<td  colspan='4'>"); 
						//				tableYsjl1 = FormHandler.getYsjlTable1(String.valueOf(flowTask.getMainId()),deptid,flowTask.getUserSeq(),"");
										functionYsjl1 = FormHandler.getYsjlJsFunction(String.valueOf(flowTask.getMainId()),deptid);
										getRequest().setAttribute("functionYsjl1", functionYsjl1);
						//				getRequest().setAttribute("tableYsjl1", tableYsjl1);
										sb.append("<input type='button' value='原始记录单校对' onclick=\"viewYsjl('0')\" class='form_bt_orange' style='width:120px;margin-left:60px'/>");
										sb.append("</td>");
										sb.append("</tr>");
										
										sb.append("<tr>");
										sb.append("<td colspan='4' align='center'>"); 
										
										sb.append("<table style=\"width: 100%;\">"); 
										sb.append("<tr>");
										sb.append("<td align='center'>"); 
										sb.append("<table width='100%' id=\"gridTableYsjl1\"></table>");
										sb.append("<div id=\"gridPagerYsjl1\"></div>");
										sb.append("</td>");
										sb.append("</tr>");
										sb.append("</table>");
										sb.append("</td>");
										sb.append("</tr>");
									}
								}else if("4".equals(specialColumn)){//选择报告
									String deptid = getDeptid();
									
									
									if("1".equals(specialType)){//编辑
										sb.append("<tr>");
										sb.append("<td  colspan='4'>"); 
										String tablenum = String.valueOf(0);
										sb.append("<input type='button' value='查看原始记录单' onclick=\"viewYsjl('1',"+tablenum+")\" class='form_bt_orange' style='width:120px;margin-left:60px'/>");
										sb.append("<input type='button' value='制作报告' onclick=\"openBg('0',"+tablenum+")\" class='form_bt_orange' style='width:100px;margin-left:60px'/>");
										sb.append("<input type='button' value='删除' onclick=\"deleteBg()\" class='form_bt_orange' style='width:80px;margin-left:10px'/>");
										sb.append("</td>");
										sb.append("</tr>");
										
										sb.append("<tr>");
										sb.append("<td colspan='4' align='center'>"); 
										
										sb.append("<table style=\"width: 100%;\">"); 
										sb.append("<tr>");
										sb.append("<td align='center'>"); 
										sb.append("<table width='100%' id=\"gridTableBg"+tablenum+"\"></table>");
										sb.append("<div id=\"gridPagerBg"+tablenum+"\"></div>");
										sb.append("</td>");
										sb.append("</tr>");
										sb.append("</table>");
										sb.append("</td>");
										sb.append("</tr>");
									}else{//查看
										sb.append("<tr>");
										sb.append("<td  colspan='4'>");
										String tablenum = String.valueOf(0);
									    sb.append("<input type='button' value='查看报告' onclick=\"openBg('1',1"+tablenum+")\" class='form_bt_orange' style='width:100px;margin-left:60px'/>");
									    sb.append("<input type='button' value='查看原始记录单' onclick=\"viewYsjl('0')\" class='form_bt_orange' style='width:120px;margin-left:60px'/>");
										
									    sb.append("</td>");
										sb.append("</tr>");
										
										sb.append("<tr>");
										sb.append("<td colspan='4' align='center'>"); 
										
										sb.append("<table style=\"width: 100%;\">"); 
										sb.append("<tr>");
										sb.append("<td align='center'>"); 
										sb.append("<table width='100%' id=\"gridTableBg1"+tablenum+"\"></table>");
										sb.append("<div id=\"gridPagerBg1"+tablenum+"\"></div>");
										sb.append("</td>");
										sb.append("</tr>");
										sb.append("</table>");
										sb.append("</td>");
										sb.append("</tr>");
									}
								}
							}
						}
						}
						
				}
				sb.append("</table>\r\n");
				sb.append("</div>\r\n");
				sb.append(columnHidden);
			sb.append("</div>\r\n");
			//选择当前tab
			String formname = formnew.getFormCnName();
			sb.append("<script type='text/javascript'>\r\n");
			sb.append("$(document).ready(function(){");
			sb.append("$('#tt').tabs('select', '"+formname+"')"); 
			sb.append( "})");
			sb.append("</script>\r\n");
			this.getRequest().setAttribute("flowid", flowid);
			this.getRequest().setAttribute("formid", formid);
			getRequest().setAttribute("columns", columns);
			getRequest().setAttribute("tableContent", sb);
			getRequest().setAttribute("formnew", formnew);
			//getRequest().setAttribute("fieldList", fieldList);
			getRequest().setAttribute("taskId", taskId);
			getRequest().setAttribute("flowtaskinfoid", flowtaskinfoid);
			getRequest().setAttribute("flag", flag);
			getRequest().setAttribute("stateid", stateid);
			getRequest().setAttribute("bodyjs", bodyjs);
			getRequest().setAttribute("waijianValue", flowTask.getMainId());
			getRequest().setAttribute("flowtypeid",flowTask.getFlowTypeId());
			return "toformedit";
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
	}

	/**
	 * 拼接html語句(修改的所有元素没有id和name)
	 * author:lishu	 2013-10-29
	 */
	public String  getUpdateHtmlNoIdAndName(AutoFormsField field,Object obj){
		StringBuffer sb = new StringBuffer();
		String type = String.valueOf(field.getPageDisplayType());
		String isPageDisplay = field.getIsPageShow().toString();//是否页面显示（0：否，1：是）
		String isReadOnly = field.getIsReadOnly().toString();//页面是否只读（0：否，1：是）
		String kongjianType = ""; //页面元素 type： hidden 还是text
		String readOnlyText = ""; //是否只读 readonly="readonly"
		String eventType = field.getEventType();//事件类型
		String eventName = field.getEventName();//事件名称
		String event = "";
		if(!StringUtil.isEmpty(eventType)){
			event = eventType + "=\"" + eventName + "()\"";
		}
		String bitian = " ";
		String message = "";
		if("NUMBER".equals(field.getFieldType())){
			message = "只允许输入数字";
			bitian += "  class='easyui-numberbox'  missingMessage='"+message+"' ";
		}else{
			if("1".equals(field.getAuthenticationType())){
				message = "必填";
				bitian += " class='easyui-validatebox' ";
			}
		}
		if("1".equals(field.getAuthenticationType())){
			message = "必填";
			bitian += " required missingMessage='"+message+"' ";
		}
		String foreignColumnName = "";
		String foreignTableName = "";
		
		if(!StringUtil.isEmpty(field.getForeignTableName())){
				foreignColumnName = field.getForeignCloumn()+","+field.getForeignDisCloumn();
				foreignTableName = field.getForeignTableName();
				
		}else{
//			String sql1 = "select tt.foreign_cloumn,tt.foreign_dis_cloumn,tt.foreign_table_name  from auto_forms_field tt " +
//			        "where tt.field_name = '"+field.getFieldName()+"'  and tt.foreign_cloumn is not null and tt.foreign_table_name is not null and tt.foreign_dis_cloumn is not null " +
//			        "and tt.forms_id in (select t.id  from auto_forms_new t where t.form_en_name = (select a.form_en_name from auto_forms_new a where a.id = "+field.getFormsId()+"))";
//			List list1 =  autoFromsService.queryListBySql(sql1);
//			if(list1.size()>0){
//				Object[] obj1 = (Object[])list1.get(0);
//				foreignColumnName = obj1[0].toString()+","+obj1[1].toString();
//				foreignTableName = obj1[2].toString();
//			}
			
		}
		
		if(obj==null){
			obj = "";
		}
		

		if("1".equals(isPageDisplay)){
			kongjianType = "text";
		}else{
			kongjianType = "hidden";
		}
		if("1".equals(isReadOnly)){
			readOnlyText = "readonly=readonly";
		}else{
			readOnlyText = "";
		}
		String defaultValue = field.getDefaultValue();//獲取默認值
		//页面显示类型（0：文本，1：时间空间，2：下拉菜单，3：文本域,4：单选框，5：复选框，6：操作人，7操作部门，8操作时间）
		if("1".equals(type)){//时间空间
			sb.append("<input type=\""+kongjianType+"\" class='finput' onClick=\"WdatePicker()\" value=\""+obj+"\" "+bitian+"/>");
		}else if("2".equals(type)){//下拉菜单
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				sb.append("<select class='fselect'  "+event+">");
				for(String value : values){
					if(value.equals(String.valueOf(obj))){
						sb.append("<option value=\""+value+"\" selected=selected>"+value+"</option>");
					}else{
						sb.append("<option value=\""+value+"\" >"+value+"</option>");
					}
				}
				sb.append("</select>");
			}
		}else if("3".equals(type)){
			if(null!=obj ){
				obj = htmlEscape(obj.toString());
			}
			sb.append("<textarea rows=\"8\" cols=\"40\" class='ftextarea'>"+obj+"</textarea>");
		}else if("4".equals(type)){//单选框
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				for(String value : values){
					if(obj!=null && value.equals(obj)){
						sb.append("<input type=\"radio\" class='finput' style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" checked=\"checked\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
					}else{
						sb.append("<input type=\"radio\" class='finput' style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
					}
				}
			}
		}else if("5".equals(type)){//复选框
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				int j = 0;
				for (int i = 0; i < values.length; i++) {
					String realValue = ","+String.valueOf(obj)+",";
					if(obj!=null && realValue.contains(values[i])){
						sb.append("<input type=\"checkbox\" class='finput' checked=\"checked\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+values[i]+"\" "+bitian+">" + values[i]);
					}else{
						sb.append("<input type=\"checkbox\" class='finput' style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+values[i]+"\" "+bitian+">" + values[i]);
					}
					if(j%MOD_CHECK==1){
						sb.append("<br/>");
					}
					j++;
				} 
			}
		}else if("6".equals(type)){//操作人
			if(obj!=null && !"".equals(obj) ){
				sb.append("<input type=\""+kongjianType+"\" class='finput' readonly=readonly value=\""+obj+"\" "+bitian+"/>");
			}else{
				sb.append("<input type=\""+kongjianType+"\" class='finput' readonly=readonly value=\""+getUserNM()+"\" "+bitian+" />");
			}
		}else if("7".equals(type)){//操作部门
			if(obj!=null && !"".equals(obj) ){
				sb.append("<input type=\""+kongjianType+"\" class='finput' readonly=readonly value=\""+obj+"\" "+bitian+"/>");
			}else{
				sb.append("<input type=\""+kongjianType+"\" class='finput' readonly=readonly value=\""+getDeptName()+"\" "+bitian+"/>");
			}
		}else if("8".equals(type)){//操作时间
			if(obj!=null && !"".equals(obj) ){
				sb.append("<input type=\""+kongjianType+"\" class='finput' readonly=readonly value=\""+obj+"\" "+bitian+"/>");
			}else{
				sb.append("<input type=\""+kongjianType+"\" class='finput' readonly=readonly value=\""+DateUtilsAll.dateToString(new Date())+"\" "+bitian+"/>");
			}
		}else if("9".equals(type)){//操作日期
			if(obj!=null && !"".equals(obj) ){
				sb.append("<input type=\""+kongjianType+"\" class='finput'  readonly=readonly value=\""+obj+"\" "+bitian+"/>");
			}else{
				sb.append("<input type=\""+kongjianType+"\" class='finput' readonly=readonly value=\""+DateUtilsAll.dateToStringShort(new Date())+"\" "+bitian+"/>");
			}
		}else if("10".equals(type)){//选择部门
			//根据部门id去查询部门名称显示表单上
			if(obj.equals("") || obj == null){
				obj = "''";
			}
			String sqlDept = "select t.org_id,t.org_name from sys_organization t where t.org_id ="+obj;
			List listDept = autoService.getDatabySql(sqlDept);//查询所有的数据项
			Object[] objDept = null;
			if(listDept != null && listDept.size() != 0){
				objDept = (Object [])listDept.get(0);
				sb.append("<input type=\"hidden\"  value=\""+objDept[0]+"\" "+bitian+">");
				sb.append("<input type=\"text\" readonly=readonly  value=\""+objDept[1]+"\" "+bitian+"'/>");
			}else{
				sb.append("<input type=\"hidden\" >");
				sb.append("<input type=\"text\" readonly=readonly "+bitian+"/>");
			}
			//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectdept('"+field.getFieldName()+"')\" />");
		}else if("11".equals(type)){//选择人员
			//根据人员id查询人员姓名显示表单上
//			if(obj.equals("") || obj == null){
//				obj = "''";
//			}
//			String sqlPerson = "select t.userid,t.username from sys_users t where t.userid="+obj;
//			List listPerson = autoService.getDatabySql(sqlPerson);//查询所有的数据项
//			Object[] objPerson = null;
//			if(listPerson != null && listPerson.size() != 0){
//				objPerson = (Object [])listPerson.get(0);
//				sb.append("<input type=\"hidden\" value=\""+objPerson[0]+"\">");
//				sb.append("<input type=\"text\" readonly=readonly value=\""+objPerson[1]+"\" class=\"tab_input\"/>");
//			}else{
//				sb.append("<input type=\"hidden\" >");
//				sb.append("<input type=\"text\" readonly=readonly class=\"tab_input\"/>");
//			}
			if(obj!=null && !"".equals(obj) ){
					sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\">");
					sb.append("<input type=\"text\" class='finput' readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\"  "+bitian+"/>");
				sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
			}else{
				sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\">");
				sb.append("<input type=\"text\" class='finput' readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\"  "+bitian+"/>");
				sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
			}
			//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
		}else if(!"".equals(foreignColumnName)&&!"".equals(foreignTableName)){//如果不满足上述条件  则判断外键是否存在
			if(obj!=null && !"".equals(obj)){
				
				//根据外键去查询外键表的id和显示值
				if(obj.equals("") || obj == null){
					obj = "''";
				}
				
				String sqlForeign = "select "+foreignColumnName+" from "+foreignTableName+" where ID = "+obj;
				List listForeign = autoService.getDatabySql(sqlForeign);//查询所有的数据项
				Object[] objForeign = null;
				if(listForeign != null && listForeign.size() != 0){
					objForeign = (Object [])listForeign.get(0);
					sb.append("<input type=\"hidden\"  value=\""+objForeign[0]+"\">");
					sb.append("<input type=\"text\" readonly=readonly value=\""+objForeign[1]+"\" "+bitian+"/>");
				}else{
					sb.append("<input type=\"hidden\" >");
					sb.append("<input type=\"text\" readonly=readonly "+bitian+"/>");
				}
			}else{
				sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\">");
				sb.append("<input type=\"text\" readonly=readonly id=\"data_"+field.getFieldName()+"\" name=\"data_"+field.getFieldName()+"\" value=\"\" "+bitian+"/>");
				sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectData('"+field.getFieldName()+"','"+field.getForeignTableName()+"','"+field.getForeignCloumn()+"','"+field.getForeignDisCloumn()+"','"+field.getCnName()+"','"+field.getDefaultValue()+"','"+field.getFormsId()+"')\" />");
			}
			//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectData('"+field.getFieldName()+"','"+field.getForeignTableName()+"','"+field.getForeignCloumn()+"','"+field.getForeignDisCloumn()+"','"+field.getCnName()+"')\" />");
		}else if("12".equals(type)){//原始记录
			if(obj != null){
				if(obj != null && !"".equals(obj)){
					sb.append("<input type=\"button\" class='finput' id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\"查看原始记录\" onclick=\"viewYsjl('"+obj+"')\"  />");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\"/>");
				}else{
					sb.append("<input type=\"button\" class='finput' id=\"bjysjl\" name=\"bjysjl\" value=\"编辑原始记录\" onclick=\"openYsjl('"+field.getFieldName()+"');\"/>");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
				}
			}else{
			}
		}else if("13".equals(type)){//文件上传
//			if(obj != null && !"".equals(obj)){
//				 String url =getRequest().getSession().getAttribute("SYS_FILEPATH").toString();
//				 String[] arr = obj.toString().split("@");
//				 String a = arr[1].replaceAll("\\\\", "/");
//				 System.out.println("a:"+a);
//				 sb.append("<a target=\"_blank\"  onclick=\"fileUpload('"+url+"/"+a+"')\">"+arr[0]+"</a>");
//				 sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+arr[0]+"\"/>");
//			}else{
//			}
		}else if("14".equals(type)){//合格证
			if(obj != null){
				if(obj != null && !"".equals(obj)){
					sb.append("<input type=\"button\" class='finput' id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\"查看合格证\" onclick=\"viewHgz('"+obj+"')\"  />");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\"/>");
				}else{
					sb.append("<input type=\"button\" class='finput' id=\"bjhgz\" name=\"bjhgz\" value=\"编辑合格证\"  onclick=\"openHgz('"+field.getFieldName()+"');\"/>");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
				}
			}else{
			}
		}else if("15".equals(type)){//产品编号
				sb.append("<textarea readonly=\"readonly\" class='ftextarea' rows=\"6\" cols=\"40\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" >"+obj+"</textarea>");
			
		}else{
			if("ID".equals(field.getFieldName())){//如果是主键则隐藏
				sb.append("<input type=\"hidden\" value=\""+obj+"\" />");
			}else{
				if(null!=obj ){
					obj = htmlEscape(obj.toString());
				}
				sb.append("<input "+readOnlyText+"  "+event+" class='finput' type=\""+kongjianType+"\" value=\""+obj+"\" />");
			}
		}
		return sb.toString();
	}
	/**
	 * 只显示当前页面
	 * author:lishu	 2014-7-16
	 */
	public String initCodeReviewUpdateOne()  throws IOException{
		
		String flowtaskinfoid = getRequest().getParameter("flowtaskinfoid");
		String stateid = this.getRequest().getParameter("stateid");
		//String formid = this.getRequest().getParameter("formid");
		String flowid = this.getRequest().getParameter("flowid");
		String taskId = this.getRequest().getParameter("taskid");
		String flag = this.getRequest().getParameter("flag");
		String backstate = StringUtil.encodingUrl(this.getRequest().getParameter("backstate"));
		String flagtype = this.getRequest().getParameter("flagtype");
		FlowTask flowTask = codeReviewService.getFlowTaskById(Long.parseLong(taskId));
		String view = "1"; 
		if(null!= this.getRequest().getParameter("view") && !"".equals(this.getRequest().getParameter("view"))){
			view = this.getRequest().getParameter("view");//view=0 查看详情
		}
	
		flowtype = codeReviewService.findFileNameById(Long.parseLong(flowid));
		String filename = flowtype.getFilename();
		String path = PubMethod.GetFlowFilePath()+filename;
		TotalFlowXmlTool fxs = new TotalFlowXmlTool(path);
		List<Flowstate> formidlist = fxs.GetFormlists();
		
		//取得当前节点的formid
		Flowstate flowstate1 = fxs.GetFlowStateByID(stateid);
		String formid = flowstate1.getForm().split(",")[0];
		AutoFormsNew formnew =  autoFormService.getAutoFormsNewById(flowstate1.getForm().split(",")[0]);
		List<StepEntity> steps = fxs.GetListByText(stateid);
		String columns = "";
		Object objs = null;//查询对象
		String tablejs = "";//拼接表单中的列表
		StringBuffer bodyjs = new StringBuffer();//事件js方法
		String functionuser = "";
		String tableuser = "";
		String tablejsid = "";//拼接列表中外键id
		int k = 1;
		boolean flowstateid = false;
		StringBuffer sb = new StringBuffer();
		sb.append("<div id='tt' class='easyui-tabs' style='width:"+formnew.getFormwidth()+"px'>");
		String columnHidden ="";
		//研发检测流程--生成委托单识别号-----------   wxj
		if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "proc0".equals(stateid)){
			getWeituodanChuli(getRequest().getParameter("mainid"),taskId);
		}
		//常规检测流程生成识别号
		if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"ddshwtd".equals(stateid)){
			String weituodanshibieh = getChangguijianceShibiehao(String.valueOf(flowTask.getMainId()),taskId);
			//自动生成样品编号
			String queryGwmitemSampSql = "select wmsys.wm_concat(t.id) from gwm_sample t where t.t_taskid = "+taskId+" and t.t_sampleno is  null";
			List gList = autoFormService.getDatabySql(queryGwmitemSampSql);
			if(null!=gList&&gList.size()>0&&null!=gList.get(0)){
				String itemSampleIds = gList.get(0).toString();
			   codeReviewService.shengchengSampleNo(itemSampleIds, weituodanshibieh);
			}
		}
		try {
				//查询表单信息
				AutoFormsNew formnew1 =  autoFormService.getAutoFormsNewById(formid);
				//查询字段信息
				List<AutoFormsField> fieldList = autoFormService.getAutoFormsFieldByformid(formid);
				 
				if(fieldList.size()>0){
					
					//如果字段信息为空
					List fieldValues = autoFormService.getAutoFormsFieldValues(formid, formnew.getFormEnName(), String.valueOf(flowTask.getMainId()));
					if(fieldValues.size() >0){
						Object[] values = (Object[])fieldValues.get(0);
						String formColumn = String.valueOf(formnew1.getFormColumn());
						if(!"0".equals(flagtype)){
							sb.append("<div title='"+formnew1.getFormCnName()+"' style='padding:20px;'>\r\n");
						}
						sb.append("<form action=\"\" id=\"pageFrom\" name=\"pageFrom\" method=\"post\">");
						sb.append("<table width='100%' border='0' align='center' class='formTableNew'>\r\n");
						
						if("1".equals(formColumn) || formnew1.getFormColumn()==null){//如果是一列显示
							if (steps!=null)
							{
								sb.append("<tr><td style='text-align:right;width:120px;'>流程名称：</td><td colspan='3'><input type='text' id='flowname' name='flowname' value='"+flowTask.getFlowName()+"' style='width:705px' readonly ='readonly' ></td>");
							}
							for (int i = 0; i < fieldList.size(); i++) {
								AutoFormsField field = fieldList.get(i);
								objs = values[i];
								if(formnew1.getColumnForigen() != null && field.getFieldName().toLowerCase().equals(formnew1.getColumnForigen().toLowerCase())){//外键的值
									tablejsid = String.valueOf(objs);
								}
								if(!field.getFieldName().equals("ID") && !"0".equals(field.getIsPageShow().toString())){//除了ID的添加
									columns += field.getFieldName() + ",";
									sb.append("<tr>");
									sb.append("<td align=\"right\">"+field.getCnName()+"：</td>");
									sb.append("<td align=\"left\">");
									sb.append(getUpdateHtml(field, objs,String.valueOf(flowTask.getMainId())));
									sb.append("</td>");
									sb.append("</tr>");
								}
								if(!StringUtil.isEmpty(field.getEventFunction())){
									bodyjs.append(field.getEventFunction());
								}
							}
							//列表展示
							String columnName = formnew1.getColumnCnName();
							String columnSql = formnew1.getColumnSql();
							String columnForigen = formnew1.getColumnForigen();
							if(!StringUtil.isEmpty(columnName) && !StringUtil.isEmpty(columnSql)){
								if("flow_task_id".equals(columnForigen.toLowerCase())){//如果外键是流程id
									tablejsid = String.valueOf(flowTask.getId());
								}
								String tablenum = String.valueOf(k);
								tablejs += FormHandler.getTableJS(String.valueOf(formnew1.getId()),tablenum, columnName,columnSql,formnew1.getColumnWidth(),tablejsid,flowstateid);
								getRequest().setAttribute("tablejs", tablejs);
								sb.append("<tr>");
								sb.append("<td colspan='2' align='center'>"); 
								sb.append("<table style=\"width: 90%;\" class=\"tableCont\">"); 
								sb.append("<tr>");
								sb.append("<td>"); 
								sb.append("<table id=\"gridTable"+tablenum+"\"></table>");
								sb.append("<div id=\"gridPager"+tablenum+"\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
							}
//							String spyj = flowTask.getSpyj()!=null?flowTask.getSpyj():"";
//							sb.append("<tr><td style='text-align:right;width:120px;'>审批意见：</td><td colspan='3'><textarea id=\"shenpiyijian\" name=\"shenpiyijian\"    class='ftextarea' readonly=\"readonly\" rospan=\"8\" colspan=\"80\" style='border: 1px solid #999;padding: 5px;width:705px;height:60px'>"+spyj+"</textarea></td>");
							
							//选择部门
							String specialColumn = formnew1.getSpecialColumn();
							Long specialColumnType = formnew1.getSpecialType();
							String specialType = formnew1.getSpecialType()!=null?formnew1.getSpecialType().toString():"";
							if("1".equals(specialColumn)){//项目列表
								//样品列表
								tablejs += FormHandler.getSampleTable(String.valueOf(flowTask.getId()));
								//检测项目列表
								tablejs += FormHandler.getItemeTable(String.valueOf(flowTask.getId()),"",specialType);
						
								//常规检测流程 调度审核委托单
								if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"ddshwtd".equals(stateid)){
									tablejs +="jQuery(\"#gridTableSample\").jqGrid('showCol','T_SAMPLENO');";
								}
							    getRequest().setAttribute("tablejs", tablejs);
								//样品/检测项目 多tab页
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样       品' style='padding:10px'>");
//								if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"ddshwtd".equals(stateid)){
//									sb.append("<input id='choosemodel' type='button'  value='生成样品编号' onclick=\"shengchengSampleNo()\" style=\"width:150px\"/>\r\n");
//								}
								sb.append("<table id=\"gridTableSample\"></table>");
								sb.append("<div id=\"gridPagerSample\"></div>");
								sb.append("</div>");
								sb.append("<div title='检测项目' style='padding:10px'>");
								
								sb.append("<table id=\"gridTableItem1\"></table>");
								sb.append("<div id=\"gridPagerItem1\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
							}else if("2".equals(specialColumn)){
								String deptid = getDeptid();
//								tableuser = FormHandler.getUserTable(String.valueOf(flowTask.getMainId()),deptid,String.valueOf(flowTask.getDeptSeq()));
//								functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),deptid);
//								getRequest().setAttribute("functionuser", functionuser);
//								getRequest().setAttribute("tableuser", tableuser);
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								
								sb.append("<table style=\"width: 100%;\">"); 
								sb.append("<tr>");
								sb.append("<td align='center'>"); 
								sb.append("<input type='button' value='分配用户' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
								sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
								sb.append("<table width='100%' id=\"gridTableUser\"></table>");
								sb.append("<div id=\"gridPagerUser\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
								
							}else if("3".equals(specialColumn)){//选择原始记录
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								
								getRequest().setAttribute("tablejs", tablejs);
                                functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid(),flowtaskinfoid);
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								if("1".equals(specialType)){//编辑
									sb.append("<input type='button' value='原始记录' onclick=\"openYsjl('0')\" class='form_bt_orange' style='width:120px;'/>");
									//常规检测流程
//									if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))){
//										sb.append("&nbsp;&nbsp;<input type='button' value='上传附件' onclick=\"itemGrid1UploadFile('gridTableSampleItem','1')\" class='form_bt_orange' style='width:120px;'/>");
//										sb.append("&nbsp;&nbsp;<input type='button' value='查看附件' onclick=\"downloaYsjlAnnex('gridTableSampleItem',1)\" class='form_bt_orange' style='width:120px;'/>");
//										sb.append("&nbsp;&nbsp;<input type='button' value='删除附件' onclick=\"deleteYsjlAnnex('gridTableSampleItem')\" class='form_bt_orange' style='width:120px;'/>");
//									}
								}else{//查看
									sb.append("<input type='button' value='原始记录单审核' onclick=\"openYsjl('1')\" class='form_bt_orange' style='width:120px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								
								
								
								
								 
							}else if("4".equals(specialColumn)){//选择报告
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('hideCol','T_JIANCEYUANNAME');";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_BGFILEPATH');";
								
								getRequest().setAttribute("tablejs", tablejs);
//                                functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid());
//								
//							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								sb.append("<input type='button' value='查看原始记录' onclick=\"openYsjl('1')\" class='form_bt_orange' style='width:120px;'/>");
								
								if("1".equals(specialType)){//编辑
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='制作报告' onclick=\"openBg('0')\" class='form_bt_orange' style='width:100px;'/>");
								}else{//查看
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='查看报告' onclick=\"openBg('1')\" class='form_bt_orange' style='width:100px;'/>");
								}
								//常规检测流程---》报告与原始记录发放节点
								if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"bgysjlff".equals(stateid)){
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='报告与原始记录发放' onclick=\"bgAndysjlfafang()\" class='form_bt_orange' style='width:170px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								 
							}
							else if("5".equals(specialColumn)){//样品/检测项目列表
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    getRequest().setAttribute("tablejs", tablejs);

							    functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid(),flowtaskinfoid);
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								if("1".equals(specialType)){
									sb.append("<input type='button' value='分配用户' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
									sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
							}
							if (steps!=null)
							{
								String isshow = "";
								if (steps.size()<=1)
								{
									isshow = "none";
								}
								if(2844==formnew1.getId()||2845==formnew1.getId()||2846==formnew1.getId()){
									sb.append("</tr>");
								}else{
									sb.append("<tr style='display:"+isshow+";' id=\"steptr\"><td style='text-align:right;'>下一步骤：</td><td>");
									int i = 0;
									for(Iterator iter = steps.iterator();iter.hasNext();)
									{
										StepEntity entity = (StepEntity)iter.next();
										if (i==0){
											sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' checked style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
										}
										else{
											sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
										}
										i++;
									}
									sb.append("</td>");
									
									sb.append("</tr>");
								}
								
							}
						}else if("2".equals(formColumn)){//如果是两列显示
							if (steps!=null)
							{
								sb.append("<tr><td style='text-align:right;width:120px;'>流程名称：</td><td colspan='3'><input type='text' id='flowname' name='flowname' value='"+flowTask.getFlowName()+"' style='border: 1px solid #999;padding: 5px;width:705px' readonly ='readonly' ></td>");
							}
							int j = 1;
							
							for (int i = 0; i < fieldList.size(); i++) {
								AutoFormsField field1 = fieldList.get(i);
								objs = values[i];
								if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))){
									if("—— ——".equals(String.valueOf(objs))){
										objs = null;
									}
								}
								if(formnew1.getColumnForigen() != null && field1.getFieldName().toLowerCase().equals(formnew1.getColumnForigen().toLowerCase())){//外键的值
									tablejsid = String.valueOf(objs);
								}
								if(!field1.getFieldName().equals("ID")){//除了ID的添加
									//页面是否显示
									if("0".equals(field1.getIsPageShow().toString())){
										//columnHidden += "<input type='hidden' id=\""+field1.getFieldName()+"\" name=\""+field1.getFieldName()+"\" value=\""+objs+"\"  />";
										continue;
									}
									//============================= 查询具体某个字段的值 END =============================
									if(j%2==1){
										sb.append("<tr>");
									}
									
									if(PubMethod.GetFlowid("flow.templetFlowId").equals(flowid) && "WAIJIAN".equals(field1.getFieldName())){
										sb.append("<input id='WAIJIAN' name='WAIJIAN' type='hidden' value='"+objs+"' />");
									}else{
										columns += field1.getFieldName() + ",";
										sb.append("<td align=\"right\">"+field1.getCnName()+"：</td>");
										sb.append("<td align=\"left\">");
										sb.append(getUpdateHtml(field1, objs ,String.valueOf(flowTask.getMainId())));
										sb.append("</td>");
									}
									
									if(j%2==0){
										sb.append("</tr>");
									}
									j++;
								}
								if(!StringUtil.isEmpty(field1.getEventFunction())){
									bodyjs.append(field1.getEventFunction());
								}
							}
//							String spyj = flowTask.getSpyj()!=null?flowTask.getSpyj():"";
//							sb.append("<tr><td style='text-align:right;width:120px;'>审批意见：</td><td colspan='3'><textarea id=\"shenpiyijian\" name=\"shenpiyijian\"   class='ftextarea' readonly=\"readonly\" rospan=\"8\" colspan=\"80\" style='border: 1px solid #999;padding: 5px;width:705px;height:60px'>"+spyj+"</textarea></td>");
							
							//列表展示
							String columnName = formnew1.getColumnCnName();
							String columnSql = formnew1.getColumnSql();
							String columnForigen = formnew1.getColumnForigen();
							if(!StringUtil.isEmpty(columnName) && !StringUtil.isEmpty(columnSql)){
								if("flow_task_id".equals(columnForigen.toLowerCase())){//如果外键是流程id
									tablejsid = String.valueOf(flowTask.getId());
								}
								String tablenum = String.valueOf(k);
								tablejs += FormHandler.getTableJS(String.valueOf(formnew1.getId()),tablenum, columnName,columnSql,formnew1.getColumnWidth(),tablejsid,flowstateid);
								getRequest().setAttribute("tablejs", tablejs);
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<table style=\"width: 100%;\">"); 
								sb.append("<tr>");
								sb.append("<td>"); 
								sb.append("<table  width='100%' id=\"gridTable"+tablenum+"\"></table>");
								sb.append("<div id=\"gridPager"+tablenum+"\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
							}
							//选择部门
							String specialColumn = formnew1.getSpecialColumn();
							String specialType = formnew1.getSpecialType()!=null?formnew1.getSpecialType().toString():"";
							if("1".equals(specialColumn)){//项目列表
								if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"gcbz".equals(stateid)){
									//样品列表
									tablejs += FormHandler.getSampleTable(taskId);
									//检测项目列表
									tablejs += FormHandler.getItemeTable(taskId,"0",String.valueOf(specialType));
									//其他检测项目列表
									//tablejs += FormHandler.getItemeTable2(taskId);
									
								    getRequest().setAttribute("tablejs", tablejs);
									//样品/检测项目 多tab页
									if("1".equals(specialColumn)){
										sb.append("<tr>");
										sb.append("<td colspan='4' align='center'>"); 
										sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
										sb.append("<div title='样       品' style='padding:10px'>");
										if(!"0".equals(flagtype)){
										sb.append("<input id='saveBtn1' type='button'  value='添 加' onclick=\"addSampleGrid()\" class='form_bt_orange'/>\r\n");
										sb.append("<input id='updateBtn1' type='button'  value='修 改'  onclick=\"updateSampleGrid()\" class='form_bt_orange'/>\r\n");
										sb.append("<input id='deleteBtn1' type='button'  value='删 除' onclick=\"deleteSampleGrid()\" class='form_bt_orange'/>\r\n");
										sb.append("<input id='deleteBtn1' type='button'  value='下载模版' onclick=\"downloadSampleModel()\" class='form_bt_orange'/>\r\n");
										sb.append("<input id='deleteBtn1' type='button'  value='模版导入' onclick=\"SampleModeImport()\" class='form_bt_orange'/>\r\n");
										}
										sb.append("<table id=\"gridTableSample\"></table>");
										sb.append("<div id=\"gridPagerSample\"></div>");
										sb.append("</div>");
										sb.append("<div title='检测项目' style='padding:10px'>");
										if(!"0".equals(flagtype)){
										sb.append("<input id='selectBtn2' type='button'  value='选择项目' onclick=\"selectItemGrid()\" class='form_bt_orange'/> &nbsp;\r\n");
										sb.append("<input id='deleteBtn2' type='button'  value='删 除' onclick=\"deleteItemGrid()\"  class='form_bt_orange'/> &nbsp;\r\n");
										sb.append("<input id='saveBtn2' type='button'  value='保存列表' onclick=\"saveItemGrid(0)\"  class='form_bt_orange'/> &nbsp;\r\n");
						//				sb.append("<input id='saveBtn2' type='button'  value='上传附件' onclick=\"itemGrid1UploadFile('gridTableItem1','0')\" class='form_bt_orange'/> &nbsp;\r\n");
										}
										sb.append("<table id=\"gridTableItem1\"></table>");
										sb.append("<div id=\"gridPagerItem1\"></div>");
										sb.append("</div>");
//										sb.append("<div title='其他检测项目' style='padding:10px'>");
//										if(!"0".equals(flagtype)){
//										sb.append("<input id='addBtn3' type='button'  value='添 加' onclick=\"addRowtoItem2()\" class='form_bt_orange'/>&nbsp;\r\n");
//										sb.append("<input id='deleteBtn3' type='button'  value='删 除' onclick=\"deleteGridItem3()\" class='form_bt_orange'/> &nbsp;\r\n");
//										sb.append("<input id='saveBtn3' type='button'  value='保存列表'  onclick=\"saveGridOtherItem(0)\" class='form_bt_orange'/> &nbsp;\r\n");
//										sb.append("<input id='saveBtn3' type='button'  value='存入数据库' onclick=\"saveDataIntoItem()\" class='form_bt_orange'/> &nbsp;\r\n");
//					//					sb.append("<input id='saveBtn2' type='button'  value='上传附件' onclick=\"itemGrid1UploadFile('gridTableItem2','0')\" class='form_bt_orange'/> &nbsp;\r\n");
//										}
//										sb.append("<table id=\"gridTableItem2\"></table>");
//										sb.append("<div id=\"gridPagerItem2\"></div>");
//										sb.append("</div>");
									    sb.append("</td>");
										sb.append("</tr>");
									}
								}else{
								
									//样品列表
									tablejs += FormHandler.getSampleTable(String.valueOf(flowTask.getId()));
									//检测项目列表
									tablejs += FormHandler.getItemeTable(String.valueOf(flowTask.getId()),"",specialType);
							
									//常规检测流程 调度审核委托单
									if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"ddshwtd".equals(stateid)){
										tablejs +="jQuery(\"#gridTableSample\").jqGrid('showCol','T_SAMPLENO');";
									}
								    getRequest().setAttribute("tablejs", tablejs);
									//样品/检测项目 多tab页
									sb.append("<tr>");
									sb.append("<td colspan='4' align='center'>"); 
									sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
									sb.append("<div title='样       品' style='padding:10px'>");
//									if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"ddshwtd".equals(stateid)){
//										sb.append("<input id='choosemodel' type='button'  value='生成样品编号' onclick=\"shengchengSampleNo()\" style=\"width:150px\"/>\r\n");
//									}
									sb.append("<table id=\"gridTableSample\"></table>");
									sb.append("<div id=\"gridPagerSample\"></div>");
									sb.append("</div>");
									sb.append("<div title='检测项目' style='padding:10px'>");
									if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"ddshwtd".equals(stateid)){
										sb.append("<input type='button' value='选择检测标准' onclick=\"updateJiancebiaozhun()\" class='form_bt_orange'  style='width:120px;'/>");
									}
									sb.append("<table id=\"gridTableItem1\"></table>");
									sb.append("<div id=\"gridPagerItem1\"></div>");
									sb.append("</div>");
									sb.append("</div>");
								    sb.append("</td>");
									sb.append("</tr>");
								}
							}else if("2".equals(specialColumn)){
								String deptid = getDeptid();
					//			tableuser = FormHandler.getUserTable(String.valueOf(flowTask.getMainId()),deptid,String.valueOf(flowTask.getDeptSeq()));
								functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),deptid,flowtaskinfoid);
								getRequest().setAttribute("functionuser", functionuser);
								getRequest().setAttribute("tableuser", tableuser);
								sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								
								sb.append("<table style=\"width: 100%;\">"); 
								sb.append("<tr>");
								sb.append("<td align='center'>"); 
								sb.append("<input type='button' value='分配用户' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
								sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
								sb.append("<table width='100%' id=\"gridTableUser\"></table>");
								sb.append("<div id=\"gridPagerUser\"></div>");
								sb.append("</td>");
								sb.append("</tr>");
								sb.append("</table>");
								sb.append("</td>");
								sb.append("</tr>");
							}else if("3".equals(specialColumn)){//选择原始记录
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								
								getRequest().setAttribute("tablejs", tablejs);
                                functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid(),flowtaskinfoid);
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								if("1".equals(specialType)){//编辑
									
									//常规检测流程
									if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))){
//										sb.append("&nbsp;&nbsp;<input type='button' value='上传附件' onclick=\"itemGrid1UploadFile('gridTableSampleItem','1')\" class='form_bt_orange' style='width:120px;'/>");
//										sb.append("&nbsp;&nbsp;<input type='button' value='查看附件' onclick=\"downloaYsjlAnnex('gridTableSampleItem',1)\" class='form_bt_orange' style='width:120px;'/>");
//										sb.append("&nbsp;&nbsp;<input type='button' value='删除附件' onclick=\"deleteYsjlAnnex('gridTableSampleItem')\" class='form_bt_orange' style='width:120px;'/>");
										sb.append("&nbsp;&nbsp;<input type='button' value='选择设备' onclick=\"xuanzeshebei('0')\" class='form_bt_orange' style='width:120px;'/>&nbsp;&nbsp;&nbsp;");
									}
									sb.append("<input type='button' value='原始记录' onclick=\"openYsjl('0')\" class='form_bt_orange' style='width:120px;'/>&nbsp;&nbsp;&nbsp;");
									sb.append("<input type='button' value='删除原始记录' onclick=\"deleteYsjl()\" class='form_bt_orange' style='width:120px;'/>");
									
									
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='删除检测参数' onclick=\"deleteJiancecanshu()\" class='form_bt_orange' style='width:120px;'/>");
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='恢复检测参数' onclick=\"huifujiancecanshu()\" class='form_bt_orange' style='width:120px;'/>");
									
									
								}else{//查看
									sb.append("<input type='button' value='原始记录单审核' onclick=\"openYsjl('1')\" class='form_bt_orange' style='width:120px;'/>");
									sb.append("&nbsp;&nbsp;<input type='button' value='查看设备' onclick=\"xuanzeshebei('1')\" class='form_bt_orange' style='width:120px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
							}else if("4".equals(specialColumn)){//选择报告
								String deptid = getDeptid();
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('hideCol','T_JIANCEYUANNAME');";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_REPORTSHIBIEH');";
								//tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_BGFILEPATH');";
								//增加选择同名报告部门代码
								tablejs +="function rowselect(id){\n";
								tablejs +="var celldata = jQuery(\"#gridTableSampleItem\").jqGrid('getCell',id,'T_BGFILEPATH');\n";
								tablejs +="if (celldata!=''&&celldata!=undefined){\n";
								//tablejs +="jQuery(\"#gridTableSampleItem\").trigger('reloadGrid');\n";
								tablejs +="var ids = jQuery(\"#gridTableSampleItem\").jqGrid('getDataIDs');\n";
								tablejs +="for(var i=0;i<ids.length;i++){\n";
								tablejs +="var celldata1 = jQuery(\"#gridTableSampleItem\").jqGrid('getCell',ids[i],'T_BGFILEPATH');\n";
								tablejs +="if (celldata==celldata1 && id!=ids[i]){\n";
								tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('setSelection',ids[i]);\n";
								tablejs +="}\n";
								tablejs +="}\n";
								tablejs +="}\n";
								tablejs +="}\n";
								
								if(!"bgsh".equals(stateid)&&!"bgpz".equals(stateid)&&!"bgqz".equals(stateid)&&!"bgysjlff".equals(stateid)){
									tablejs +="jQuery(\"#gridTableSampleItem\").jqGrid('showCol','T_YSJLFILEPATH');";
								}
								getRequest().setAttribute("tablejs", tablejs);
                                functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid(),flowtaskinfoid);
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								sb.append("<input type='button' value='查看原始记录' onclick=\"openYsjl('1')\" class='form_bt_orange' style='width:120px;'/>");
								
								if("1".equals(specialType)){//编辑
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='制作报告' onclick=\"openBg('0')\" class='form_bt_orange' style='width:100px;'/>");
								}else{//查看
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='查看报告' onclick=\"openBg('1')\" class='form_bt_orange' style='width:100px;'/>");
								}
								//常规检测流程---》报告与原始记录发放节点
								if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"bgysjlff".equals(stateid)){
									sb.append("&nbsp;&nbsp;&nbsp;<input type='button' value='报告与原始记录发放' onclick=\"bgAndysjlfafang()\" class='form_bt_orange' style='width:170px;'/>");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								
							}
							else if("5".equals(specialColumn)){//样品/检测项目列表
								//样品/检测项目列表
								tablejs += FormHandler.getGwmItemSampleTableByTaskId(String.valueOf(flowTask.getId()),stateid,this.getDeptid(),flowtaskinfoid,"");
							    getRequest().setAttribute("tablejs", tablejs);

							    functionuser = FormHandler.getUserJsFunction(String.valueOf(flowTask.getMainId()),this.getDeptid(),flowtaskinfoid);
								
							    getRequest().setAttribute("functionuser", functionuser);
							    sb.append("<tr>");
								sb.append("<td colspan='4' align='center'>"); 
								sb.append("<div id='tt1' class='easyui-tabs' style='width:750px;height：600px'>");
								sb.append("<div title='样品/检测项目列表' style='padding:10px'>");
								if("1".equals(specialType)){
									sb.append("<input type='button' value='分配用户' onclick=\"fenpeiUser()\" class='form_bt_orange' />&nbsp;&nbsp;");
									sb.append("<input type='button' value='清空人员' onclick=\"deleteUser()\" class='form_bt_orange' />");
								}
								sb.append("<table id=\"gridTableSampleItem\"></table>");
								sb.append("<div id=\"gridPagerSampleItem\"></div>");
								sb.append("</div>");
								sb.append("</div>");
							    sb.append("</td>");
								sb.append("</tr>");
								
							}
							
							if (steps!=null)
							{
								//sb.append("<tr><td style='text-align:right;width:120px;'>流程名称：</td><td><input type='text' id='flowname' name='flowname' value='"+flowTask.getFlowName()+"'></td>");
								String isshow = "";
								if (steps.size()<=1)
								{
									isshow = "none";
								}
								
								if(2844==formnew1.getId()||2845==formnew1.getId()||2846==formnew1.getId() || "0".equals(flagtype)){
									sb.append("</tr>");
								}else{
									sb.append("<tr style='display:"+isshow+";' id=\"steptr\"><td style='text-align:right;'>下一步骤：</td><td>");
									int i = 0;
									for(Iterator iter = steps.iterator();iter.hasNext();)
									{
										StepEntity entity = (StepEntity)iter.next();
										if (i==0){
											sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' checked style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
										}
										else{
											sb.append("<input type='radio' name='steptype' id='steptype"+i+"' value='"+entity.getId()+"' style='border:0px;padding: 5px;width: 50px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;'/>"+entity.getText()+"&nbsp;&nbsp;&nbsp;&nbsp;") ;
										}
										i++;
									}
									sb.append("</td>");
									
									sb.append("</tr>");
								}
							}
						}
						sb.append("<table width='100%' border='0' align='center' class='formTableNew'>\r\n");
						sb.append("<td align='center' >\r\n");
						
						/**********************************生成样品编号　START***************************************/
						if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"ddshwtd".equals(stateid)){
							sb.append("<input id='choosemodel' type='button'  value='项目分配' class='form_bt_orange' onclick=\"fenpeiItem()\" style=\"width:100px\"/>\r\n");
							
						}
						if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))){
							if("ddshwtd".equals(stateid) || "ksrwfp".equals(stateid) || "syrwjs".equals(stateid) || "txysjl".equals(stateid)
									|| "shysjl".equals(stateid) || "bgbz".equals(stateid) || "bgsh".equals(stateid)){
								sb.append("<input id='wentifankui' type='button'  value='问题反馈' class='form_bt_orange' onclick=\"WentiFankuiMore()\" style=\"width:150px\"/>\r\n");
							}
						}
						/**********************************生成样品编号　END***************************************/
						/**********************************研发检测流程　START***************************************/
						if(flowid.equals(PubMethod.GetFlowid("flow.yanfajianceflowid"))){
							if("proc1".equals(stateid)){
								sb.append("<input type='hidden' id='RENWUYUANNAME' name='RENWUYUANNAME' value=\"\"/>\r\n");
							}
							if("proc0".equals(stateid) || "proc1".equals(stateid) || "proc3".equals(stateid)){
								sb.append("<input id='wentifankui' type='button'  value='问题反馈' class='form_bt_orange' onclick=\"WentiFankui()\" style=\"width:150px\"/>\r\n");
							}
							if("proc2".equals(stateid)){
								sb.append("<input id='wentifankui' type='button'  value='问题反馈' class='form_bt_orange' onclick=\"WentiFankuiMore()\" style=\"width:150px\"/>\r\n");
							}
							if("proc2".equals(stateid)){
//								sb.append("<input id='xuanzeshebei' type='button'  value='选择设备' class='form_bt_orange' onclick=\"YFxuanzeshebei('0')\" style=\"width:150px\"/>\r\n");
//								sb.append("<input id='yuanshijilu' type='button'  value='原始记录' class='form_bt_orange' onclick=\"YFyuanshijilu('0')\" style=\"width:150px\"/>\r\n");
							}
							if("proc3".equals(stateid)){
								sb.append("<input id='bianzhibaogao' type='button'  value='编制报告' class='form_bt_orange' onclick=\"YFbianzhibaogao('1')\" style=\"width:150px\"/>\r\n");
//								sb.append("<input id='yuanshijilu' type='button'  value='原始记录' class='form_bt_orange' onclick=\"YFyuanshijilu('1')\" style=\"width:150px\"/>\r\n");
							}
							if("proc4".equals(stateid) || "proc5".equals(stateid)){
								sb.append("<input id='bianzhibaogao' type='button'  value='报告审核' class='form_bt_orange' onclick=\"YFbianzhibaogao('1')\" style=\"width:150px\"/>\r\n");
//								sb.append("<input id='yuanshijilu' type='button'  value='原始记录审核' class='form_bt_orange' onclick=\"YFyuanshijilu('1')\" style=\"width:150px\"/>\r\n");
//								sb.append("<input id='bianzhibaogao' type='button'  value='任务交接' class='form_bt_orange' onclick=\"renwujiaojie()\" style=\"width:150px\"/>\r\n");
							}
						}
						/**********************************研发检测流程　END***************************************/
						
						/**********************************按钮生成 列表　START***************************************/
						String buttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type,t.fitter_condition from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 1 ";
						List buttonList = autoService.getDatabySql(buttonSql);
						if(buttonList != null && buttonList.size() != 0 ){
							for (int j = 0; j < buttonList.size(); j++) {
								Object[] obj = (Object[])buttonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"buttonOnclick("+obj[1]+",'"+obj[0]+"','"+obj[2]+"','"+obj[3]+"','"+obj[4]+"')\"/>\r\n");
							}
						}
						/**********************************按钮生成　END***************************************/
						/**********************************自动确认样品　START***************************************/
						String ziDongbuttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 8 ";
						List ziDongButtonList = autoService.getDatabySql(ziDongbuttonSql);
						if(ziDongButtonList != null && ziDongButtonList.size() != 0 ){
							for (int j = 0; j < ziDongButtonList.size(); j++) {
								Object[] obj = (Object[])ziDongButtonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" value=\""+obj[0]+"\" style=\"width:120px;\" onclick=\"ziDongQueRen("+obj[1]+",'"+obj[0]+"','"+obj[2]+"','"+obj[3]+"')\"/>\r\n");
							}
						}
						/**********************************自动确认样品　END***************************************/
						
						/**********************************查看施工单　START***************************************/
						String sgdbuttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 9 ";
						List sgdButtonList = autoService.getDatabySql(sgdbuttonSql);
						if(sgdButtonList != null && sgdButtonList.size() != 0 ){
							for (int j = 0; j < sgdButtonList.size(); j++) {
								Object[] obj = (Object[])sgdButtonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" value=\""+obj[0]+"\" style=\"width:120px;\" onclick=\"viewshigongdan()\"/>\r\n");
							}
						}
						/**********************************查看施工单　END***************************************/
						
						
						/**********************************生成原始记录按钮　START***************************************/
						String ysjlSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 2 ";
						List ysjlList = autoService.getDatabySql(ysjlSql);
						if(ysjlList != null && ysjlList.size() != 0 ){
							for (int j = 0; j < ysjlList.size(); j++) {
								Object[] obj = (Object[])ysjlList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openYsjl("+obj[3]+")\"/>\r\n");
							}
						}
						/**********************************生成原始记录按钮　END***************************************/
						/**********************************生成军检原始记录按钮　START***************************************/
						String jjysjlSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 5 ";
						List jjysjlList = autoService.getDatabySql(jjysjlSql);
						if(jjysjlList != null && jjysjlList.size() != 0 ){
							for (int j = 0; j < jjysjlList.size(); j++) {
								Object[] obj = (Object[])jjysjlList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openjjYsjl("+obj[3]+")\"/>\r\n");
							}
						}
						/**********************************生成军检原始记录按钮　END***************************************/
						/**********************************生成合格证按钮　START***************************************/
						String hgzSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 3 ";
						List hgzList = autoService.getDatabySql(hgzSql);
						if(hgzList != null && hgzList.size() != 0 ){
							for (int j = 0; j < hgzList.size(); j++) {
								Object[] obj = (Object[])hgzList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openHgz("+obj[3]+")\"/>\r\n");
							}
						}
						/**********************************生成合格证按钮　END***************************************/
						
						/**********************************生成其他按钮 编辑　START***************************************/
						String otherSql = " select t.id, t.button_name,t.mode_path,t.choose_form_id from print_report_mode t where t.choose_form_id = "+formid;
						List otherList = autoService.getDatabySql(otherSql);
						if(otherList != null && otherList.size() != 0 ){
							for (int j = 0; j < otherList.size(); j++) {
								Object[] obj = (Object[])otherList.get(j);
								if("委托单打印".equals(obj[1].toString())){
								  sb.append("<input type=\"hidden\" class=\"form_bt_orange\" id=\"printwtd\" style=\"width:120px;\" value=\""+obj[1]+"\" onclick=\"viewOtherForm('"+obj[2]+"','"+obj[0]+"',"+obj[3]+",'"+obj[1]+"')\"/>\r\n");
								}else{
									sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[1]+"\" onclick=\"viewOtherForm('"+obj[2]+"','"+obj[0]+"',"+obj[3]+",'"+obj[1]+"')\"/>\r\n");
								}
							}
						}
						/**********************************生成其他按钮　END***************************************/
						
						/**********************************生成其他按钮 查看　START***************************************/
						String otherLook = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 4 ";
						List otherLookList = autoService.getDatabySql(otherLook);
						if(otherLookList != null && otherLookList.size() != 0 ){
							for (int j = 0; j < otherLookList.size(); j++) {
								Object[] obj = (Object[])otherLookList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" style=\"width:120px;\" value=\""+obj[0]+"\" onclick=\"openOtherLook('"+obj[3]+"','"+obj[1]+"')\"/>\r\n");
							}
						}
						/**********************************生成其他按钮　END***************************************/
						
						/**********************************选择设备　START***************************************/
						String sheBeibuttonSql = "select t.button_name,t.by_table_name_id,t.by_table_column,t.operate_type from auto_forms_button t where t.this_table_name_id = "+formid +" and t.button_type = 6 ";
						List sheBeiButtonList = autoService.getDatabySql(sheBeibuttonSql);
						if(sheBeiButtonList != null && sheBeiButtonList.size() != 0 ){
							for (int j = 0; j < sheBeiButtonList.size(); j++) {
								Object[] obj = (Object[])sheBeiButtonList.get(j);
								sb.append("<input type=\"button\" class=\"form_bt_orange\" value=\""+obj[0]+"\" onclick=\"chooseEquipment("+obj[1]+",'"+obj[0]+"','"+obj[2]+"','"+obj[3]+"')\"/>\r\n");
							}
						}
						/**********************************选择设备　END***************************************/
						
						
						if("proc5".equals(stateid)){
						  sb.append("<input id='queryhuizongbg' type='button'  value='查看报告' class='form_bt_orange' onclick=\"editHuizongbg('1')\"/>\r\n");
						}
						if(PubMethod.GetFlowid("flow.templetFlowId").equals(flowid)){
							sb.append("<input id='updatemoban' type='button' value='查看信息' onclick='updateMoBan();' class='form_bt_orange' />\r\n");
						}
						if(!"0".equals(flagtype)){
							if(!"gcjd".equals(stateid)){
								
								sb.append("<input id='saveupdateBtn' type='button'  value='保 存' class='form_bt_orange' />\r\n");
							}
							if(flowid.equals(PubMethod.GetFlowid("flow.yanfajianceflowid")) && "gcsh".equals(stateid)){
								sb.append("<input id='saveBtn' type='button'  value='发 放' class='form_bt_orange' />\r\n");
							}else{
								sb.append("<input id='saveBtn' type='button'  value='提 交' class='form_bt_orange' />\r\n");
							}
						}
						sb.append("<input type='button' id='closeBtn' value='取 消' class='form_bt_grey' />\r\n");
						sb.append("</td>\r\n");
						sb.append("</table>\r\n");
						sb.append(columnHidden);
				
					}
				}
				sb.append("</table>\r\n");
				sb.append("</div>\r\n");
				sb.append(columnHidden);
			sb.append("</div>\r\n");
			//选择当前tab
			String formname = formnew.getFormCnName();
			sb.append("<script type='text/javascript'>\r\n");
			sb.append("$(document).ready(function(){");
			sb.append("$('#tt').tabs('select', '"+formname+"')"); 
			sb.append( "})");
			sb.append("</script>\r\n");
			
//			//常规检测流程 调度审核委托单 费用
//			String itemFeiyong ="";
//			if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"ddshwtd".equals(stateid)){
//				String feiyongSql = "select sum(a.t_jiancemoney) from (select  distinct t.t_gmw_item_id,t.t_jiancemoney  from gwm_item_sample t where t.t_taskid = "+taskId+" " +
//						            " and t.t_gmw_item_id in (select distinct s.t_gmw_item_id from gwm_item_sample s where s.T_TASKID ="+taskId+" and s.t_jiancemoney is not null)) a ";
//				List feiYongList = autoFormService.getDatabySql(feiyongSql);
//				if(null!=feiYongList&&feiYongList.size()>0&&null!=feiYongList.get(0)){
//					itemFeiyong = feiYongList.get(0).toString();
//					//查询样品数量
//					String sampleCountSql = " select sum(t.t_samplecount) from gwm_sample t where t.t_taskid=27884 and t.t_samplecount is not null ";
//					List sampleCountList = autoFormService.getDatabySql(sampleCountSql);
//					if(null!=sampleCountList&&sampleCountList.size()>0){
//						
//					}
//				}
//				
//			}
//			getRequest().setAttribute("itemFeiyong", itemFeiyong);
			this.getRequest().setAttribute("flowid", flowid);
			this.getRequest().setAttribute("formid", formid);
			getRequest().setAttribute("columns", columns);
			getRequest().setAttribute("tableContent", sb);
			getRequest().setAttribute("formnew", formnew);
			//getRequest().setAttribute("fieldList", fieldList);
//			getRequest().setAttribute("xmList", list4.size());
//			getRequest().setAttribute("ypList", list5.size());
			getRequest().setAttribute("taskId", taskId);
			getRequest().setAttribute("flowtaskinfoid", flowtaskinfoid);
			getRequest().setAttribute("flag", flag);
			getRequest().setAttribute("backstate", backstate);
			getRequest().setAttribute("stateid", stateid);
			getRequest().setAttribute("bodyjs", bodyjs);
			getRequest().setAttribute("waijianValue", flowTask.getMainId());
			getRequest().setAttribute("flowtypeid",flowTask.getFlowTypeId());
			getRequest().setAttribute("view", view);
//			getRequest().setAttribute("mainFlowId", flowTask.getMainFlowId());
//			getRequest().setAttribute("userseq", flowTask.getUserSeq());
//			getRequest().setAttribute("shiyanbh", flowTask.getShiyanbh());
			return "toformedit";
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	
	
	/**
	 * 拼接html語句（添加的）
	 * author:lishu	 2013-10-29
	 */
	public String  getAddHtml(AutoFormsField field,String entityTableId){
		StringBuffer sb = new StringBuffer();
		String type = String.valueOf(field.getPageDisplayType());
		String isPageDisplay = field.getIsPageShow().toString();//是否页面显示（0：否，1：是）
		String isReadOnly = field.getIsReadOnly().toString();//页面是否只读（0：否，1：是）
		String kongjianType = ""; //页面元素 type： hidden 还是text
		String readOnlyText = ""; //是否只读 readonly="readonly"
		String eventType = field.getEventType();//事件类型
		String eventName = field.getEventName();//事件名称
		String event = "";
		if(!StringUtil.isEmpty(eventType)){
			event = eventType + "=\"" + eventName + "()\"";
		}
		String bitian = " ";
		String message = "";
		if("NUMBER".equals(field.getFieldType())){
			message = "只允许输入数字";
			bitian += "  class='easyui-numberbox'  missingMessage='"+message+"' ";
		}else{
			if("1".equals(field.getAuthenticationType())){
				message = "必填";
				bitian += " class='easyui-validatebox' ";
			}
		}
		if("1".equals(field.getAuthenticationType())){
			message = "必填";
			bitian += " required missingMessage='"+message+"' ";
		}
		if("1".equals(isPageDisplay)){
			kongjianType = "text";
		}else{
			kongjianType = "hidden";
		}
		if("1".equals(isReadOnly)){
			readOnlyText = "readonly=readonly";
		}else{
			readOnlyText = "";
		}
		String defaultValue = field.getDefaultValue();//獲取默認值
		//页面显示类型（0：文本，1：时间空间，2：下拉菜单，3：文本域,4：单选框，5：复选框，6：操作人，7操作部门，8操作时间）
		if("1".equals(type)){//时间空间
			if("1".equals(isReadOnly)){
				sb.append("<input "+readOnlyText+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\" type=\""+kongjianType+"\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\"\" "+bitian+"/>");
			}else{
				sb.append("<input "+readOnlyText+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\" type=\""+kongjianType+"\" id=\""+field.getFieldName()+"\" onClick=\"WdatePicker()\" name=\""+field.getFieldName()+"\" value=\"\" "+bitian+"/>");
			}
		}else if("2".equals(type)){//下拉菜单
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				if("1".equals(isReadOnly)){
					sb.append("<select id=\""+field.getFieldName()+"\" disabled class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
				}else{
					sb.append("<select id=\""+field.getFieldName()+"\"  class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
				}
				for(String value : values){
					sb.append("<option value=\""+value+"\">"+value+"</option>");
				}
				sb.append("</select>");
			}
		}else if("3".equals(type)){//文本域
			sb.append("<textarea "+readOnlyText+" rows=\"8\" cols=\"34\" class='ftextarea' id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" "+bitian+"></textarea>");
		}else if("4".equals(type)){//单选框
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				for(String value : values){
					if("1".equals(isReadOnly)){
						sb.append("<input type=\"radio\" disabled style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
					}else{
						sb.append("<input type=\"radio\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
					}
				}
			}
		}else if("5".equals(type)){//复选框
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				int j = 0;
				for (int i = 0; i < values.length; i++) {
					if("1".equals(isReadOnly)){
						sb.append("<input type=\"checkbox\" disabled style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" " +
								"name=\""+field.getFieldName()+"\" value=\""+values[i]+"\">" + values[i]);
					}else{
						sb.append("<input type=\"checkbox\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" " +
							"name=\""+field.getFieldName()+"\" value=\""+values[i]+"\">" + values[i]);
					}
					if(j%MOD_CHECK==1){
						sb.append("<br/>");
					}
					j++;
				}
			}
		}else if("6".equals(type)){//操作人
			sb.append("<input type=\""+kongjianType+"\" class='finput'  readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+getUserNM()+"\" "+bitian+"/>");
		}else if("7".equals(type)){//操作部门
			sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"  readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+getDeptName()+"\" "+bitian+"/>");
		}else if("8".equals(type)){//操作时间
			sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"   readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+DateUtilsAll.dateToString(new Date())+"\" "+bitian+"/>");
		}else if("9".equals(type)){//操作日期
			sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"  readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+DateUtilsAll.dateToStringShort(new Date())+"\" "+bitian+"/>");
		}else if("10".equals(type)){//选择部门
			sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\">");
			sb.append("<input type=\"text\" class='finput'  readonly=readonly id=\"dept_"+field.getFieldName()+"\" name=\"dept_"+field.getFieldName()+"\" value=\"\" "+bitian+"/>");
			if("1".equals(field.getAuthenticationType())){
				sb.append("<img src=\"images/xh.png\" align=\"absmiddle\"></img>");
			}
			sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectdept('"+field.getFieldName()+"')\" />");
		}else if("11".equals(type)){//选择人员
			sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\">");
			sb.append("<input type=\"text\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\" readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\"\" "+bitian+"/>");
			if("1".equals(field.getAuthenticationType())){
				sb.append("<img src=\"images/xh.png\" align=\"absmiddle\"></img>");
			}
			sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
		}else if(!StringUtil.isEmpty(field.getForeignTableName())){//如果不满足上述条件  则判断外键是否存在
			sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\">");
			sb.append("<input type=\"text\"    readonly=readonly id=\"data_"+field.getFieldName()+"\" name=\"data_"+field.getFieldName()+"\" value=\"\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\" />");
			if("1".equals(field.getAuthenticationType())){
				sb.append("<img src=\"images/xh.png\" align=\"absmiddle\"></img>");
			}
			sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectData('"+field.getFieldName()+"','"+field.getForeignTableName()+"','"+field.getForeignCloumn()+"','"+field.getForeignDisCloumn()+"','"+field.getCnName()+"','"+field.getDefaultValue()+"','"+field.getFormsId()+"')\" />");
		}else if("12".equals(type)){//原始记录
			sb.append("<input type=\"button\" id=\"bjysjl\" name=\"bjysjl\" value=\"编辑原始记录\" class=\"button_b\" onclick=\"openYsjl('"+field.getFieldName()+"');\" "+bitian+"/>");
			sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
		}else if("13".equals(type)){//文件上传
			if("1".equals(isReadOnly)){
				//sb.append("<input type=\"file\" readonly id=\"uploadfile\" name=\"uploadfile\"  "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 260px;\" />");
				sb.append(FormHandler.getUploadHtml(getRequest().getContextPath(),entityTableId,field.getFieldName(),"y"));
			}else{
				sb.append(FormHandler.getUploadHtml(getRequest().getContextPath(),entityTableId,field.getFieldName(),"n"));
				//sb.append("<span id=\"file_"+field.getFieldName()+"\"></span>");
			}
	//		sb.append("<input type=\"hidden\"  id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
			
    	}else if("14".equals(type)){//合格证
			sb.append("<input type=\"button\" id=\"bjhgz\" name=\"bjhgz\" value=\"编辑合格证\" class=\"button_b\" onclick=\"openHgz('"+field.getFieldName()+"');\" "+bitian+"/>");
			sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
		}else if("15".equals(type)){//产品编号
			sb.append("<input type=\"text\" class='finput'   id=\"cpbh_"+field.getFieldName()+"\" name=\"cpbh_"+field.getFieldName()+"\" value=\"\" "+bitian+"/>");
			sb.append("<img src=\"web/images/icon3.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"cpbh('cpbh_"+field.getFieldName()+"','"+field.getFieldName()+"');\" />");
			sb.append("</br><textarea class='ftextarea' rows=\"6\" cols=\"40\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" ></textarea>");
		}else if("19".equals(type)){//编号规则
			String no = autoFormService.queryCunstomNumber(field.getCustomNum(), field.getCustomId());
			sb.append("<input type=\"text\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"  readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+no+"\" "+bitian+"/>");
		}else if("20".equals(type)){//试验编号
			sb.append("<input type=\"text\"   id=\""+field.getFieldName()+"\"  name=\""+field.getFieldName()+"\" readonly=\"readonly\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
			sb.append("<input type=\"hidden\"   id=\"TEST_ID\"  name=\"TEST_ID\"  style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
			sb.append("<img src=\"web/images/form_icon_1.gif\" width=\"23\" height=\"23\" border=\"0\" onclick=\"chooseCustomNo('"+field.getFieldName()+"');\" title=\"选择\" style=\"margin-bottom:-6px;cursor:hand;\" />");
		}else if("21".equals(type)){//根据材料牌号自动变
				if("1".equals(isReadOnly)){
					sb.append("<select id=\""+field.getFieldName()+"\" disabled class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
				}else{
					sb.append("<select id=\""+field.getFieldName()+"\"  class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
				}
				sb.append("</select>");
	    }else{
			sb.append("<input "+readOnlyText+"  "+event+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\" type=\""+kongjianType+"\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\"\"  "+bitian+"/>");
		}
		if("1".equals(field.getAuthenticationType())&&(!"10".equals(type)&&!"11".equals(type)&&StringUtil.isEmpty(field.getForeignTableName()))){
			sb.append("<img src=\"images/xh.png\" align=\"absmiddle\"></img>");
		}
		return sb.toString();
	}
	
	/**
	 * 拼接html語句(修改的)
	 * author:lishu	 2013-10-29
	 */
	public String  getUpdateHtml(AutoFormsField field,Object obj, String entityTableId){
		StringBuffer sb = new StringBuffer();
		String xzgyId = "";
		String type = String.valueOf(field.getPageDisplayType());
		String isPageDisplay = field.getIsPageShow().toString();//是否页面显示（0：否，1：是）
		String isReadOnly = field.getIsReadOnly().toString();//页面是否只读（0：否，1：是）
		String kongjianType = ""; //页面元素 type： hidden 还是text
		String readOnlyText = ""; //是否只读 readonly="readonly"
		String eventType = field.getEventType();//事件类型
		String eventName = field.getEventName();//事件名称
		String event = "";
		if(!StringUtil.isEmpty(eventType)){
			event = eventType + "=\"" + eventName + "()\"";
		}
		
		String bitian = " ";
		String message = "";
		if("NUMBER".equals(field.getFieldType())){
			message = "只允许输入数字";
			bitian += "  class='easyui-numberbox'  missingMessage='"+message+"' ";
		}else{
			if("1".equals(field.getAuthenticationType())){
				message = "必填";
				bitian += " class='easyui-validatebox' ";
			}
		}
		if("1".equals(field.getAuthenticationType())){
			message = "必填";
			bitian += " required missingMessage='"+message+"' ";
		}
		String foreignColumnName = "";
		String foreignTableName = "";
		
		if(!StringUtil.isEmpty(field.getForeignTableName())){
				foreignColumnName = field.getForeignCloumn()+","+field.getForeignDisCloumn();
				foreignTableName = field.getForeignTableName();
		}else{
//			String sql1 = "select tt.foreign_cloumn,tt.foreign_dis_cloumn,tt.foreign_table_name  from auto_forms_field tt " +
//			        "where tt.field_name = '"+field.getFieldName()+"'  and tt.foreign_cloumn is not null and tt.foreign_table_name is not null and tt.foreign_dis_cloumn is not null " +
//			        "and tt.forms_id in (select t.id  from auto_forms_new t where t.form_en_name = (select a.form_en_name from auto_forms_new a where a.id = "+field.getFormsId()+"))";
//			List list1 =  autoFromsService.queryListBySql(sql1);
//			if(list1.size()>0){
//				Object[] obj1 = (Object[])list1.get(0);
//				foreignColumnName = obj1[0].toString()+","+obj1[1].toString();
//				foreignTableName = obj1[2].toString();
//			}
		}
		if(obj==null){
			obj = "";
		}
		
		
		if("1".equals(isPageDisplay)){
			kongjianType = "text";
		}else{
			kongjianType = "hidden";
		}
		if("1".equals(isReadOnly)){
			readOnlyText = "readonly=readonly";
		}else{
			readOnlyText = "";
		}
		String defaultValue = field.getDefaultValue();//獲取默認值
		//页面显示类型（0：文本，1：时间空间，2：下拉菜单，3：文本域,4：单选框，5：复选框，6：操作人，7操作部门，8操作时间）
		if("1".equals(type)){//时间空间
			if("1".equals(isReadOnly)){
				sb.append("<input "+readOnlyText+"   style=\"border: 1px solid #999;padding: 5px;width: 250px;\" type=\""+kongjianType+"\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\" "+bitian+"/>");
			}else{
				sb.append("<input "+readOnlyText+"  style=\"border: 1px solid #999;padding: 5px;width: 250px;\" type=\""+kongjianType+"\" id=\""+field.getFieldName()+"\" onClick=\"WdatePicker()\" name=\""+field.getFieldName()+"\" value=\""+obj+"\" "+bitian+"/>");
			}
		}else if("2".equals(type)){//下拉菜单
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				if("1".equals(isReadOnly)){
					sb.append("<select id=\""+field.getFieldName()+"\" disabled class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
				}else{
					sb.append("<select id=\""+field.getFieldName()+"\" class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
				}
				for(String value : values){
					if(value.equals(String.valueOf(obj))){
						sb.append("<option value=\""+value+"\" selected=selected>"+value+"</option>");
					}else{
						sb.append("<option value=\""+value+"\" >"+value+"</option>");
					}
				}
				sb.append("</select>");
			}
		}else if("3".equals(type)){//文本域
			if(null!=obj ){
				obj = htmlEscape(obj.toString());
			}
			sb.append("<textarea "+readOnlyText+" rows=\"8\"  class='ftextarea' cols=\"40\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" "+bitian+" >"+obj+"</textarea>");
		}else if("4".equals(type)){//单选框
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				for(String value : values){
					if("1".equals(isReadOnly)){
						if(obj!=null && value.equals(obj)){
							sb.append("<input type=\"radio\" disabled style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" checked=\"checked\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
						}else{
							sb.append("<input type=\"radio\" disabled style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
						}
					}else{
						if(obj!=null && value.equals(obj)){
							sb.append("<input type=\"radio\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" checked=\"checked\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
						}else{
							sb.append("<input type=\"radio\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+value+"\" "+bitian+">" + value);
						}
					}
				}
			}
		}else if("5".equals(type)){//复选框
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				int j = 0;
				for (int i = 0; i < values.length; i++) {
					String realValue = ","+String.valueOf(obj)+",";
					if("1".equals(isReadOnly)){
						if(obj!=null && realValue.contains(values[i])){
							sb.append("<input type=\"checkbox\" disabled checked=\"checked\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+values[i]+"\"  "+bitian+">" + values[i]);
						}else{
							sb.append("<input type=\"checkbox\" disabled style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+values[i]+"\" "+bitian+">" + values[i]);
						}
					}else{
						if(obj!=null && realValue.contains(values[i])){
							sb.append("<input type=\"checkbox\" checked=\"checked\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+values[i]+"\"  "+bitian+">" + values[i]);
						}else{
							sb.append("<input type=\"checkbox\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+values[i]+"\" "+bitian+">" + values[i]);
						}
					}
					if(j%MOD_CHECK==1){
						sb.append("<br/>");
					}
					j++;
				} 
			}
		}else if("6".equals(type)){//操作人
			sb.append("<input type=\""+kongjianType+"\" class='finput'  readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+getUserNM()+"\" />");
		}else if("7".equals(type)){//操作部门
			if(obj == null || "".equals(obj) ){
				sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"   readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+getDeptName()+"\" />");
			}else{
				sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"   readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\" />");
			}
		}else if("8".equals(type)){//操作时间
			sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"   readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+DateUtilsAll.dateToString(new Date())+"\" "+bitian+"/>");
		}else if("9".equals(type)){//操作日期
      	    sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"   readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+DateUtilsAll.dateToStringShort(new Date())+"\" "+bitian+"/>");
		}else if("10".equals(type)){//选择部门
			if(obj == null || "".equals(obj) ){
				obj = "''";
			}
			//根据部门id去查询部门名称显示表单上
			String sqlDept = "select t.org_id,t.org_name from sys_organization t where t.org_id ="+obj;
			List listDept = autoService.getDatabySql(sqlDept);//查询所有的数据项
			Object[] objDept = null;
			if(listDept != null && listDept.size() != 0){
				objDept = (Object [])listDept.get(0);
				sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\"  value=\""+objDept[0]+"\">");
				sb.append("<input type=\"text\" class='finput'  readonly=readonly id=\"dept_"+field.getFieldName()+"\" name=\"dept_"+field.getFieldName()+"\" value=\""+objDept[1]+"\" "+bitian+"/>");
			}else{
				sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\">");
				sb.append("<input type=\"text\" class='finput'  readonly=readonly id=\"dept_"+field.getFieldName()+"\" name=\"dept_"+field.getFieldName()+"\" "+bitian+"/>");
			}
			//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectdept('"+field.getFieldName()+"')\" />");
			
			String whetherShow = "select tt.is_read_only,tt.id  from auto_forms_field tt  where tt.field_name = '"+field.getFieldName()+"'  and tt.forms_id ="+field.getFormsId()+" ";
			List list2 =  codeReviewService.queryListBySql(whetherShow);;
			if(list2!=null&&list2.size()>0){
				Object[] obj1 = (Object[])list2.get(0);
				if("0".equals(obj1[0].toString())){//否
					sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectdept('"+field.getFieldName()+"')\" />");
					
				}else{//是
					
				}
			}
		}else if("11".equals(type)){//选择人员
			//根据人员id查询人员姓名显示表单上
//			if(obj == null || "".equals(obj) ){
//				obj = "''";
//			}
//			String sqlPerson = "select t.userid,t.username from sys_users t where t.userid="+obj;
//			List listPerson = autoService.getDatabySql(sqlPerson);//查询所有的数据项
//			Object[] objPerson = null;
//			if(listPerson != null && listPerson.size() != 0){
//				objPerson = (Object [])listPerson.get(0);
//				sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\" value=\""+objPerson[0]+"\">");
//				sb.append("<input type=\"text\" readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+objPerson[1]+"\" "+bitian+"/>");
//			}else{
//				sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\">");
//				sb.append("<input type=\"text\" readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" "+bitian+"/>");
//			}
			if(obj!=null && !"".equals(obj) ){
					sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\">");
					sb.append("<input type=\"text\" class='finput' readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\"  class=\"tab_input\" "+bitian+"/>");
				//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
			}else{
				sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\">");
				sb.append("<input type=\"text\" class='finput' readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\"  class=\"tab_input\" "+bitian+"/>");
				//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
			}
			//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
			String whetherShow = "select tt.is_read_only,tt.id  from auto_forms_field tt  where tt.field_name = '"+field.getFieldName()+"'  and tt.forms_id ="+field.getFormsId()+" ";
			List list2 =  codeReviewService.queryListBySql(whetherShow);;
			if(list2!=null&&list2.size()>0){
				Object[] obj1 = (Object[])list2.get(0);
				if("0".equals(obj1[0].toString())){//否
					sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
					
				}else{//是
					
				}
			}

		}else if(!"".equals(foreignColumnName)&&!"".equals(foreignTableName)){//如果不满足上述条件  则判断外键是否存在
			if(obj!=null && !"".equals(obj)){
				String sql2 = "select tt.foreign_cloumn,tt.foreign_dis_cloumn,tt.foreign_table_name  from auto_forms_field tt " +
				        "where tt.field_name = '"+field.getFieldName()+"'  and tt.foreign_cloumn is not null and tt.foreign_table_name is not null and tt.foreign_dis_cloumn is not null " +
				        "and tt.forms_id in (select t.id  from auto_forms_new t where t.form_en_name = (select a.form_en_name from auto_forms_new a where a.id = "+field.getFormsId()+"))";
				List list3 =  codeReviewService.queryListBySql(sql2);
				if(!StringUtil.isEmpty(field.getForeignTableName())){
						foreignColumnName = field.getForeignCloumn()+","+field.getForeignDisCloumn();
						foreignTableName = field.getForeignTableName();
						
				}else if(null!=list3&&list3.size()>0){
					Object[] obj1 = (Object[])list3.get(0);
					foreignColumnName = obj1[0].toString()+","+obj1[1].toString();
					foreignTableName = obj1[2].toString();
				}
				//根据外键去查询外键表的id和显示值
				if(obj.equals("") || obj == null){
					obj = "''";
				}
				String sqlForeign = "select "+foreignColumnName+" from "+foreignTableName+" where ID = "+obj;
				List listForeign = autoService.getDatabySql(sqlForeign);//查询所有的数据项
				Object[] objForeign = null;
				if(listForeign != null && listForeign.size() != 0){
					objForeign = (Object [])listForeign.get(0);
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+objForeign[0]+"\">");
					sb.append("<input type=\"text\" class='finput' readonly=readonly id=\"data_"+field.getFieldName()+"\" name=\"data_"+field.getFieldName()+"\" value=\""+objForeign[1]+"\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
				}else{
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\">");
					sb.append("<input type=\"text\" class='finput' readonly=readonly id=\"data_"+field.getFieldName()+"\" name=\"data_"+field.getFieldName()+"\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
				}
				//sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectData('"+field.getFieldName()+"','"+field.getForeignTableName()+"','"+field.getForeignCloumn()+"','"+field.getForeignDisCloumn()+"','"+field.getCnName()+"','"+field.getDefaultValue()+"')\" />");
				String whetherShow = "select tt.is_read_only,tt.id  from auto_forms_field tt  where tt.field_name = '"+field.getFieldName()+"'  and tt.forms_id ="+field.getFormsId()+" ";
				List list2 =  codeReviewService.queryListBySql(whetherShow);;
				if(list2!=null&&list2.size()>0){
					Object[] obj1 = (Object[])list2.get(0);
					if("0".equals(obj1[0].toString())){//否
						sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectData('"+field.getFieldName()+"','"+field.getForeignTableName()+"','"+field.getForeignCloumn()+"','"+field.getForeignDisCloumn()+"','"+field.getCnName()+"','"+field.getDefaultValue()+"','"+field.getFormsId()+"')\" />");
						
					}else{//是
						
					}
				}
			}else{
				sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\">");
				sb.append("<input type=\"text\" readonly=readonly id=\"data_"+field.getFieldName()+"\" name=\"data_"+field.getFieldName()+"\" value=\"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
				sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectData('"+field.getFieldName()+"','"+field.getForeignTableName()+"','"+field.getForeignCloumn()+"','"+field.getForeignDisCloumn()+"','"+field.getCnName()+"','"+field.getDefaultValue()+"','"+field.getFormsId()+"')\" />");
			}
		}
		else if("12".equals(type)){//原始记录
			if(obj != null){
				if(obj != null && !"".equals(obj)){
					sb.append("<input type=\"button\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\"查看原始记录\" onclick=\"viewYsjl('"+obj+"')\" class=\"button_b\" />");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\"/>");
				}else{
					sb.append("<input type=\"button\" id=\"bjysjl\" name=\"bjysjl\" value=\"编辑原始记录\" class=\"button_b\" onclick=\"openYsjl('"+field.getFieldName()+"');\" "+bitian+"/>");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
				}
			}else{
			}
		}
		else if("13".equals(type)){//文件上传
			if("1".equals(isReadOnly)){
				sb.append(FormHandler.getUploadHtml(getRequest().getContextPath(),entityTableId,field.getFieldName(),"y"));
			}else{
				sb.append(FormHandler.getUploadHtml(getRequest().getContextPath(),entityTableId,field.getFieldName(),"n"));
			}
//			
//			if(obj != null && !"".equals(obj)){
//				String url = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();
//				 //String[] arr = obj.toString().split("@");
//				// String a = arr[1].replaceAll("\\\\", "/");
//				 String a = url + "\\"+obj;
//				 sb.append("<a target=\"_blank\"  onclick=\"fileUpload('"+a+"')\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 260px;\">"+obj+"</a>");
//				 sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\"/>");
//			}else{
//				if("1".equals(isReadOnly)){
//					sb.append("<input type=\"file\" readonly id=\"uploadfile\" name=\"uploadfile\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 260px;\" />");
//				}else{
//					sb.append("<input type=\"file\" id=\"uploadfile\" name=\"uploadfile\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 260px;\"/>");
//				}
//				sb.append("<input type=\"hidden\"  id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" class=\"button_b\" />");
//			}
		}else if("14".equals(type)){//合格证
			if(obj != null){
				if(obj != null && !"".equals(obj)){
					sb.append("<input type=\"button\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\"查看合格证\" onclick=\"viewHgz('"+obj+"')\" "+bitian+" />");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\"/>");
				}else{
					sb.append("<input type=\"button\" id=\"bjhgz\" name=\"bjhgz\" value=\"编辑合格证\" class=\"button_b\" onclick=\"openHgz('"+field.getFieldName()+"');\" "+bitian+"/>");
					sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
				}
			}else{
			}
		}else if("15".equals(type)){//产品编号
				sb.append("<textarea readonly=\"readonly\"  class='ftextarea' rows=\"6\" cols=\"40\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" >"+obj+"</textarea>");
			
		}else if("19".equals(type)){//编号规则
//			if(obj==null || "".equals(obj)){
//				String no = autoFormService.queryCunstomNumber(field.getCustomNum(), field.getCustomId());
//				sb.append("<input type=\"text\" class='finput' readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+no+"\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
//			}else{
//				sb.append("<input type=\"text\"   id=\""+field.getFieldName()+"\"  name=\""+field.getFieldName()+"\" value=\""+obj+"\" readonly=\"readonly\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
//			}
			sb.append("<input type=\"text\"   id=\""+field.getFieldName()+"\"  name=\""+field.getFieldName()+"\" value=\""+obj+"\" readonly=\"readonly\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 170px;\"/>");
//			sb.append("&nbsp;&nbsp;<input type=\"button\" class=\"button_b\" onclick=\"weituodanshibiehao('"+field.getFieldName()+"');\"id=\"\" name=\"\" value=\"生成识别号\" style=\"width:75px\">");
			
		}else if("20".equals(type)){//试验编号
			if(obj==null || "".equals(obj)){
				sb.append("<input type=\"text\"   id=\""+field.getFieldName()+"\"  name=\""+field.getFieldName()+"\" readonly=\"readonly\" "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
				sb.append("<input type=\"hidden\"   id=\"TEST_ID\"  name=\"TEST_ID\"  style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
				sb.append("<img src=\"web/images/form_icon_1.gif\" width=\"23\" height=\"23\" border=\"0\" onclick=\"chooseCustomNo('"+field.getFieldName()+"');\" title=\"选择\" style=\"margin-bottom:-6px;cursor:hand;\" />");
				
			}else{
				sb.append("<input type=\"text\"   id=\""+field.getFieldName()+"\"  name=\""+field.getFieldName()+"\" value=\""+obj+"\" readonly=\"readonly\"  "+bitian+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"/>");
			}
		}else if("21".equals(type)){//根据材料牌号自动变
			if("1".equals(isReadOnly)){
				sb.append("<select id=\""+field.getFieldName()+"\" disabled class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
			}else{
				sb.append("<select id=\""+field.getFieldName()+"\"  class='fselect' name=\""+field.getFieldName()+"\" "+bitian+" "+event+">");
			}
			sb.append("</select>");
		}else{
			if("ID".equals(field.getFieldName())){//如果是主键则隐藏
				sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\" />");
			}else{
				if(null!=obj ){
					obj = htmlEscape(obj.toString());
				}
				sb.append("<input "+readOnlyText+" "+event+" "+event+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\" type=\""+kongjianType+"\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+obj+"\" "+bitian+"/>");
			}
		}
		return sb.toString();
	}
	
	public static String htmlEscape(String strData)
	{
	    if (strData == null)
	    {
	        return "";
	    }
	    strData = replaceString(strData, "&", "&amp;");
	    strData = replaceString(strData, "<", "&lt;");
	    strData = replaceString(strData, ">", "&gt;");
	    strData = replaceString(strData, "'", "&apos;");
	    strData = replaceString(strData, "\"", "&quot;");
	    return strData;
	}
	public static String replaceString(String strData, String regex, String replacement)
	{
		if (strData == null)
		{
			return null;
		}
		int index;
		index = strData.indexOf(regex);
		String strNew = "";
		if (index >= 0)
		{
			while (index >= 0)
			{
				strNew += strData.substring(0, index) + replacement;
				strData = strData.substring(index + regex.length());
				index = strData.indexOf(regex);
			}
			strNew += strData;
			return strNew;
		}
		return strData;
	}
	/**
	 * 拼接html語句（查看的）
	 * author:lishu	 2013-10-29
	 */
	public String  getAddHtmlView(AutoFormsField field){
		StringBuffer sb = new StringBuffer();
		String type = String.valueOf(field.getPageDisplayType());
		String isPageDisplay = field.getIsPageShow().toString();//是否页面显示（0：否，1：是）
		String isReadOnly = field.getIsReadOnly().toString();//页面是否只读（0：否，1：是）
		String kongjianType = ""; //页面元素 type： hidden 还是text
		String readOnlyText = ""; //是否只读 readonly="readonly"
		String bitian = " ";
		String message = "";
		if("NUMBER".equals(field.getFieldType())){
			message = "只允许输入数字";
			bitian += "  class='easyui-numberbox'  missingMessage='"+message+"' ";
		}else{
			if("1".equals(field.getAuthenticationType())){
				message = "必填";
				bitian += " class='easyui-validatebox' ";
			}
		}
		if("1".equals(field.getAuthenticationType())){
			message = "必填";
			bitian += " required missingMessage='"+message+"' ";
		}
		if("1".equals(isPageDisplay)){
			kongjianType = "text";
		}else{
			kongjianType = "hidden";
		}
		if("1".equals(isReadOnly)){
			readOnlyText = "readonly=readonly";
		}else{
			readOnlyText = "";
		}
		String defaultValue = field.getDefaultValue();//獲取默認值
		//页面显示类型（0：文本，1：时间空间，2：下拉菜单，3：文本域,4：单选框，5：复选框，6：操作人，7操作部门，8操作时间）
		if("1".equals(type)){//时间空间
				sb.append("<input "+readOnlyText+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\" type=\""+kongjianType+"\" id=\""+field.getFieldName()+"\" onClick=\"WdatePicker()\" name=\""+field.getFieldName()+"\" value=\"\" />");
		}else if("2".equals(type)){//下拉菜单
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				sb.append("<select id=\""+field.getFieldName()+"\" style=\"border: 1px solid #999;padding: 5px;width: 255px;\" name=\""+field.getFieldName()+"\" >");
				for(String value : values){
					sb.append("<option value=\""+value+"\">"+value+"</option>");
				}
				sb.append("</select>");
			}
		}else if("3".equals(type)){//文本域
			sb.append("<textarea class='ftextarea' rows=\"8\" cols=\"40\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" ></textarea>");
		}else if("4".equals(type)){//单选框
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				for(String value : values){
					sb.append("<input type=\"radio\"  style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" name=\""+field.getFieldName()+"\" value=\""+value+"\" >" + value);
				}
			}
		}else if("5".equals(type)){//复选框
			if(!StringUtil.isEmpty(defaultValue)){
				String[] values = defaultValue.split(",");
				for(String value : values){
					sb.append("<input type=\"checkbox\" style=\"border:none;width:20px; padding-left:0;height:auto;line-height:auto;\" " +
							"name=\""+field.getFieldName()+"\" value=\""+value+"\" >" + value);
				}
			}
		}else if("6".equals(type)){//操作人
			sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"  readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+getUserNM()+"\" />");
		}else if("7".equals(type)){//操作部门
			sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"  readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+getDeptName()+"\" />");
		}else if("8".equals(type)){//操作时间
			sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\" readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+DateUtilsAll.dateToString(new Date())+"\" />");
		}else if("9".equals(type)){//操作日期
			sb.append("<input type=\""+kongjianType+"\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"  readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\""+DateUtilsAll.dateToStringShort(new Date())+"\" />");
		}else if("10".equals(type)){//选择部门
			sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\">");
			sb.append("<input type=\"text\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"  readonly=readonly id=\"dept_"+field.getFieldName()+"\" name=\"dept_"+field.getFieldName()+"\" value=\"\" />");
			sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectdept('"+field.getFieldName()+"')\" />");
		}else if("11".equals(type)){//选择人员
			sb.append("<input type=\"hidden\" id=\"user_"+field.getFieldName()+"\" name=\"user_"+field.getFieldName()+"\">");
			sb.append("<input type=\"text\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"  readonly=readonly id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\"\" />");
			sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectperson('"+field.getFieldName()+"')\" />");
		}else if(!StringUtil.isEmpty(field.getForeignTableName())){//如果不满足上述条件  则判断外键是否存在
			sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\">");
			sb.append("<input type=\"text\" style=\"border: 1px solid #999;padding: 5px;width: 250px;\"  readonly=readonly id=\"data_"+field.getFieldName()+"\" name=\"data_"+field.getFieldName()+"\" value=\"\" />");
			sb.append("<img src=\"web/images/form_icon_1.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"selectData('"+field.getFieldName()+"','"+field.getForeignTableName()+"','"+field.getForeignCloumn()+"','"+field.getForeignDisCloumn()+"','"+field.getCnName()+"','"+field.getDefaultValue()+"','"+field.getFormsId()+"')\" />");
		}else if("12".equals(type)){//原始记录
			sb.append("<input type=\"button\" id=\"bjysjl\" name=\"bjysjl\" value=\"编辑原始记录\" class=\"button_b\" onclick=\"openYsjl('"+field.getFieldName()+"');\" />");
			sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
		}else if("13".equals(type)){//文件上传
			sb.append("<input type=\"file\" id=\"uploadfile\" name=\"uploadfile\"  "+bitian+"/>");
			sb.append("<input type=\"hidden\"  id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
		}else if("14".equals(type)){//合格证
			sb.append("<input type=\"button\" id=\"bjhgz\" name=\"bjhgz\" value=\"编辑合格证\" class=\"button_b\" onclick=\"openHgz('"+field.getFieldName()+"');\" />");
			sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" />");
		}else if("15".equals(type)){//产品编号
			sb.append("<input type=\"text\"  id=\"cpbh_"+field.getFieldName()+"\" name=\"cpbh_"+field.getFieldName()+"\" value=\"\" />");
			sb.append("<img src=\"web/images/icon3.gif\" style=\"cursor:hand; vertical-align: middle;\" onclick=\"cpbh('cpbh_"+field.getFieldName()+"','"+field.getFieldName()+"');\" />");
			sb.append("</br><textarea class='ftextarea' rows=\"6\" cols=\"40\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" ></textarea>");
		}else{
			sb.append("<input "+readOnlyText+" style=\"border: 1px solid #999;padding: 5px;width: 250px;\" type=\""+kongjianType+"\" id=\""+field.getFieldName()+"\" name=\""+field.getFieldName()+"\" value=\"\" />");
		}
		return sb.toString();
	}
	
	
	public String chooseDatalist() throws IOException{
		String tablename = this.getRequest().getParameter("tablename");
		String colname = this.getRequest().getParameter("colname");
		String disname = this.getRequest().getParameter("disname");
		String cnname = this.getRequest().getParameter("cnname");
		String flowid = getRequest().getParameter("flowid");
		String fileColname = this.getRequest().getParameter("fileColname");
		String formid = this.getRequest().getParameter("formid");
		String fileName = this.getRequest().getParameter("fileName");
		String byTableValueId = this.getRequest().getParameter("byTableValueId");
		
		String disnameshow = "";
		String disnameshow1 = "{'ID':'\"+row."+colname+"+\"'";
		String headershow = "";
		String[] disnamearray = disname.split(",");
		String tableIdSql = "select t.id from auto_forms_new t where t.form_en_name = '"+tablename+"'";
		List tableList = autoFormService.getDatabySql(tableIdSql);
		StringBuffer sb = new StringBuffer();
		StringBuffer qb = new StringBuffer();
		String queryColumns = "";
		for(int i=0;i<disnamearray.length;i++){
			String columnCnNameSql = "select cn_name from auto_forms_field t where t.field_name = '"+disnamearray[i]+"' and t.forms_id = '"+tableList.get(0).toString()+"'";
			List disCnNameList = autoFormService.getDatabySql(columnCnNameSql);
			disnameshow += "{name:'"+disnamearray[i]+"',index:'"+disnamearray[i]+"', width:100},";
			disnameshow1 += ",'"+disnamearray[i]+"':'\"+row."+disnamearray[i]+"+\"'";
			headershow += ",'"+disCnNameList.get(0)+"'";
			/********************************************查询条件生成  START*************************************/
			
			qb.append("\""+disnamearray[i]+"\":encodeURIComponent(jQuery('#"+disnamearray[i]+"').val()),");
			queryColumns += disnamearray[i]+",";
			sb.append(disCnNameList.get(0)+"：<input type=\"text\" class=\"input\" style=\"width:150px;\" id=\""+disnamearray[i]+"\" name=\""+disnamearray[i]+"\" value=\"\" />");
			
		}
		disnameshow1+="}";
		getRequest().setAttribute("queryValue", qb);
		getRequest().setAttribute("queryColumns", queryColumns);
		getRequest().setAttribute("queryContent", sb);
		
		/****************************************查询条件生成  END****************************************/
		
		this.getRequest().setAttribute("headershow", headershow);
		this.getRequest().setAttribute("disnameshow", disnameshow);
		this.getRequest().setAttribute("tablename", tablename);
		this.getRequest().setAttribute("colname", colname);
		this.getRequest().setAttribute("disname", disname);
		this.getRequest().setAttribute("cnname", cnname);
		this.getRequest().setAttribute("fileColname", fileColname);
		this.getRequest().setAttribute("disnameshow1", disnameshow1);
		this.getRequest().setAttribute("flowid", flowid);
		this.getRequest().setAttribute("formid", formid);
		this.getRequest().setAttribute("fileName", fileName);
		this.getRequest().setAttribute("byTableValueId", byTableValueId);
		return "chooseDatalistpage";
	}
	
	/**
	 * 保存开始节点数据(第一个节点保存)
	 */
	public void saveBeginFormData() throws Exception{
		PrintWriter out = this.getResponse().getWriter();
		try{
			String ids = getRequest().getParameter("id");
			String flowid = getRequest().getParameter("flowid");
			String flag = getRequest().getParameter("flag");
			String gg = getRequest().getParameter("gg");
			String stepidsubmit = getRequest().getParameter("stepid");
			String formid = getRequest().getParameter("formid");
			String stateid = getRequest().getParameter("stateid");
			String flowname = getRequest().getParameter("flowname");
			String stepid = getRequest().getParameter("steptype");
			String mobanId = getRequest().getParameter("mainid");//技术条件模板审核流程：模板数据的id值 wxj
			String entityTableId = getRequest().getParameter("entityTableId");//实体表ID （统一规则生成的）
			String flowtaskId = getRequest().getParameter("flowtaskId");
			
			List files = getUploadfile();
			if (files!=null)
			{
				for (int i = 0 ; i < files.size() ; i++) 
				{ 
					String fileName = (String) getUploadfileFileName().get(i);
					String fileType = fileName.substring((fileName.lastIndexOf("."))+1, fileName.length());
					File ff = new File(files.get(i).toString());
					if(ff.length()>0)
					{
						ActionContext ac = ActionContext.getContext();
				        ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
				        String url = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();
				       // String url = sc.getRealPath("/") + File.separator + "autoannex" + File.separator + "file" + File.separator;
						//url += "\\"+fileName;
				        //String url = sc.getRealPath("/") + File.separator + "auto" + File.separator + "file" + File.separator;
						File file = new File(url);
						if ( ! (file.exists())  &&   ! (file.isDirectory()))  {
			                 boolean  creadok  =  file.mkdirs();
			                 if (creadok)  {
			                    System.out.println( " ok:创建文件夹成功！ " );
			                } else  {
			                    System.out.println( " err:创建文件夹失败！ " );                    
			                } 
			            } 
						String address = url + "/" + getUploadfileFileName().get(i);
						FileOutputStream fos = new FileOutputStream(address); 
						FileInputStream fis = new FileInputStream(files.get(i).toString()); 
						byte[] buffer = new byte[1024]; 
						int len = 0; 
						while ((len = fis.read(buffer)) > 0) 
						{ 
							fos.write(buffer, 0, len);
						} 
						fos.close();
						fis.close();
					}
				}
			}
			
			//取得字段类型是文件的元素
			List fileColumnList = new ArrayList();
			List checkBoxList = new ArrayList();
			List<AutoFormsField> fieldList = autoFormService.getAutoFormsFieldByformid(formid);
			for(int i = 0; i<fieldList.size();i++){
				AutoFormsField aff = fieldList.get(i);
				if("13".equals(aff.getPageDisplayType().toString())){
					fileColumnList.add(aff.getFieldName());
				}else if("5".equals(aff.getPageDisplayType().toString())){
					checkBoxList.add(aff.getFieldName());
				}
			}
			
			//===================================保存实例 START=======================================
			String columns = getRequest().getParameter("columns");//页面所有的列
			//查询表单信息
			AutoFormsNew formnew =  autoFormService.getAutoFormsNewById(formid);
			String bsql = "ID,";//拼接sql语句
			String asql = entityTableId+",";
			Long mainId = 0l;//实例id
			int fileNameIndex = 0;
			if(columns != null){
				String[] columnss = columns.split(",");
				for(String column : columnss){
					String columnValue = "";
					bsql += column + ",";
					if(fileColumnList.contains(column)){
						if(uploadfileFileName != null && !"".equals(uploadfileFileName.get(fileNameIndex))){
							columnValue = uploadfileFileName.get(fileNameIndex).toString();
							fileNameIndex++;
						}
					}else if(checkBoxList.contains(column)){//如果是复选框
						String[] values = getRequest().getParameterValues(column);
						columnValue=org.apache.commons.lang.StringUtils.join(values,",");
					}else{
						columnValue = getRequest().getParameter(column);
					}
					if(columnValue == null||"".equals(columnValue)){
						//常规检测流程 空值用—— ——代替
						if(PubMethod.GetFlowid("flow.changguiFlowId").equals(flowid)&&"3881".equals(formid)){
							asql += "'— —',";
						}else if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "4121".equals(formid)){
							asql += "'— —',";
						}else{
							asql += "'',";
						}
						
					}else{
						columnValue = columnValue.replace("'", "''");
						asql += "'" + columnValue +"',";
					}
				}
				if(PubMethod.GetFlowid("flow.changguiFlowId").equals(flowid)&&"3881".equals(formid)){
					bsql +=  "T_WEITUOREN,";
					asql += "'" + this.getUserId() +"',";
				}
				
				String sql = "insert into "+formnew.getFormEnName()+"("+bsql.substring(0,bsql.length()-1)+")values("+asql.substring(0,asql.length()-1)+")";
				if(PubMethod.GetFlowid("flow.templetFlowId").equals(flowid)){//技术条件模板流程：给流程表单添加外键---模板id wxj
					sql = "insert into "+formnew.getFormEnName()+"("+bsql.substring(0,bsql.length()-1)+",waijian)values("+asql.substring(0,asql.length()-1)+",'"+mobanId+"')";
					String sql1 = "update TDM_ITEM_TEMPLATE t set t.SHENHESTATE = '审核中' where t.id="+mobanId;
					autoService.executeSql(sql1);
				}
				autoService.executeSql(sql);

				String cxxlSql = " select SEQ_"+formnew.getFormEnName()+".nextval from dual "; 
				List listSeq = autoService.getDatabySql(cxxlSql);
				if(listSeq != null && listSeq.size() != 0){
					mainId = Long.parseLong(listSeq.get(0).toString()) - 1;
				}
			}
			
			//===================================保存实例 END=======================================
			
				//===================================保存流程状态 START=======================================
				String path = this.getPath(flowid);
				TotalFlowXmlTool fxs = new TotalFlowXmlTool(path);
				Flowstate beforflowstate = fxs.GetFlowStateByID(stateid);
				Flowstate flowstate = beforflowstate;
				Flowstate flowstate2 = fxs.GetNextState(stepid);
				//保存任务
				String ftflowstateid = "";
				String ftflowstatename = "";
				String ftnextRoleIds ="";
				String ftnextRoleNames ="";
				String ftnextUsersId ="";
				String ftnextUsersName = "";
				String ftnextDept = "";
				String ftnextDeptId = "";
				Long ftaddUserId = null;
				String ftaddUserName = "";
				Long ftstate = null;
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				String addTime = sdf.format(System.currentTimeMillis());
//				FlowTask flowTask = new FlowTask();
			
				if("submit".equals(flag)){
					ftflowstateid = flowstate2.getStateid();
					ftflowstatename = flowstate2.getState();
					if (!flowstate2.getRoleIds().equals(""))
					{
						ftnextRoleIds = ","+flowstate2.getRoleIds()+",";
					}
					else{
						ftnextRoleIds = "";
					}
					ftnextRoleNames = flowstate2.getRoleNames();
					
					//常规检测流程下一操作人是批准人
					if(PubMethod.GetFlowid("flow.changguiFlowId").equals(flowid)&&"3881".equals(formid)){
						String pizhunName="";
						String pizhurenId = getRequest().getParameter("T_PIZHUNREN");
						String userSql = " select t.username  from sys_users t where t.userid= "+pizhurenId;
						List userNameList = autoService.getDatabySql(userSql);
						if(null!=userNameList&&userNameList.size()>0&&null!=userNameList.get(0)){
							pizhunName = userNameList.get(0).toString();
						}
						ftnextUsersId = pizhurenId;
						ftnextUsersName = pizhunName;
					}else{
						if (!flowstate2.getUserIds().equals(""))
						{
							ftnextUsersId = ","+flowstate2.getUserIds()+",";
						}
						ftnextUsersName = flowstate2.getUserNames();
					}
					
					ftnextDept = flowstate2.getDept();
					ftnextDeptId = flowstate2.getDeptid();
					String userId = ServletActionContext.getRequest().getSession().getAttribute("TDM_USER_ID").toString();
					String userNm = ServletActionContext.getRequest().getSession().getAttribute("username").toString();
					ftaddUserId = Long.parseLong(userId);
					ftaddUserName = userNm;
					ftstate = 0l;
				}else{
					ftflowstateid = flowstate.getStateid();
					ftflowstatename = "草稿";
					if (!flowstate.getRoleIds().equals(""))
					{
						ftnextRoleIds = ","+flowstate.getRoleIds()+",";
					}else{
						ftnextRoleIds ="";
					}
					ftnextRoleNames = flowstate.getRoleNames();
					if (!flowstate.getUserIds().equals(""))
					{
						ftnextUsersId = ","+flowstate.getUserIds()+",";
					}else{
						ftnextUsersId = "";
					}
					ftnextUsersName = flowstate.getUserNames();
					ftnextDept = flowstate.getDept();
					ftnextDeptId = flowstate.getDeptid();
					String userId = ServletActionContext.getRequest().getSession().getAttribute("TDM_USER_ID").toString();
					String userNm = ServletActionContext.getRequest().getSession().getAttribute("username").toString();
					ftaddUserId = Long.parseLong(userId);
					ftaddUserName = userNm;
					ftstate = 5l;
				}
				
				String flowtaskSql = "insert into flow_task " +
						             " (id, flow_name, flow_type_id, flow_state_id, flow_state_name, flow_action_type, next_roles_id, next_roles_name, next_users_id, next_users_name, add_time, add_user_id, add_user_name, flow_remark, state, next_dept_id, next_dept, huc_users_id, isjiaji, main_id, table_name, fenzhiflowcount, spyj, back_state, back_option,faqirenid) values  " +
						             "("+flowtaskId+",'"+flowname+"',"+flowid+",'"+ftflowstateid+"','"+ftflowstatename+"',null,'"+ftnextRoleIds+"','"+ftnextRoleNames+"','"+ftnextUsersId+"','"+ftnextUsersName+"',to_date('"+addTime+"','yyyy-MM-dd hh24:mi:ss'),"+ftaddUserId+",'"+ftaddUserName+"','',"+ftstate+",'"+ftnextDeptId+"','"+ftnextDept+"','', '',"+entityTableId+",'"+formnew.getFormEnName()+"',null, '', null, '',"+ftaddUserId+")";
				autoFormService.executeSql(flowtaskSql);
				//保存状态信息
				
				List<Flowstate> lists = fxs.GetNextFlowStateByID(stateid);
				for(int i=0;i<lists.size();i++){
					Flowstate stateentity = lists.get(i);
					FlowTaskInfo flowTaskInfo = new FlowTaskInfo();
					
					flowTaskInfo.setNextRolesName(stateentity.getRoleNames());
					flowTaskInfo.setNextUsersName(stateentity.getUserNames());
					flowTaskInfo.setNextDept(stateentity.getDept());
					flowTaskInfo.setNextDeptid(stateentity.getDeptid());
					flowTaskInfo.setFlowtaskid(Long.parseLong(flowtaskId));
					flowTaskInfo.setState(0l);
					if("submit".equals(flag)){
						flowTaskInfo.setFlowStateId(flowstate2.getStateid());
						flowTaskInfo.setFlowStateName(flowstate2.getState());
						//常规检测流程 ----第一节点提交   下一操作人是批准人
						if(PubMethod.GetFlowid("flow.changguiFlowId").equals(flowid)&&"3881".equals(formid)){
							
							String pizhunName="";
							String pizhurenId = getRequest().getParameter("T_PIZHUNREN");
							String userSql = " select t.username  from sys_users t where t.userid= "+pizhurenId;
							List userNameList = autoService.getDatabySql(userSql);
							if(null!=userNameList&&userNameList.size()>0&&null!=userNameList.get(0)){
								pizhunName = userNameList.get(0).toString();
							}
							flowTaskInfo.setNextUsersId(","+pizhurenId+",");
							flowTaskInfo.setNextUsersName(","+pizhunName+",");
						}else if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "4121".equals(formid) ){
							//研发检测流程 下一操作人
							String PIZHUNRENYUAN = getRequest().getParameter("PIZHUNRENYUAN");
							flowTaskInfo.setNextUsersId(","+PIZHUNRENYUAN+",");
						}
						//如果流程是常规流程，整车流程或者研究流程的话，流程表添加可拉回信息
						if (flowid.equals("2121")||flowid.equals("2241")||flowid.equals("2181")){
							flowTaskInfo.setIslahui(1l);
							flowTaskInfo.setLahuistateid(flowstate.getStateid());
							flowTaskInfo.setLahuistatename(flowstate.getState());
							flowTaskInfo.setChulirenid(","+getUserId()+",");
							flowTaskInfo.setChulirenname(getUserNM());
						}
					}else{
						flowTaskInfo.setFlowStateId(flowstate.getStateid());
						flowTaskInfo.setFlowStateName(flowstate.getState());
						if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "4121".equals(formid) ){
							//研发检测流程 下一操作人
							String user_PIZHUNRENYUAN = getRequest().getParameter("user_PIZHUNRENYUAN");
							flowTaskInfo.setNextUsersId(","+user_PIZHUNRENYUAN+",");
						}
					}
					if (!stateentity.getRoleIds().equals(""))
					{
						flowTaskInfo.setNextRolesId(","+stateentity.getRoleIds()+",");
					}else{
						flowTaskInfo.setNextRolesId("");
					}
					
					codeReviewService.saveFlowTaskInfo(flowTaskInfo);
				}
				
				if("submit".equals(flag)){
					//保存操作明细
					saveFlowDetail(flowtaskId,flowid,beforflowstate,flowstate2,"流程操作","");
				}
				//===================================保存流程状态 END=======================================
			out.print("{\"result\":\"success\",\"taskid\":\""+flowtaskId+"\"}");
		}catch(Exception exp){
			exp.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}
	
	/**
	 * 发起页流程修改的保存方法
	 * @throws Exception
	 */
	public void saveUpdateFormData() throws Exception{
		PrintWriter out = this.getResponse().getWriter();
		String flag = getRequest().getParameter("flag");
		try{
			
			//存文件
			List files = getUploadfile();
			if (files!=null)
			{
				for (int i = 0 ; i < files.size() ; i++) 
				{ 
					String fileName = (String) getUploadfileFileName().get(i);
					String fileType = fileName.substring((fileName.lastIndexOf("."))+1, fileName.length());
					File ff = new File(files.get(i).toString());
					if(ff.length()>0)
					{
						ActionContext ac = ActionContext.getContext();
				        ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
				        String url = PubMethod.GetFilepathfromproperties("zhiliangka");
				       // String url = sc.getRealPath("/") + File.separator + "autoannex" + File.separator + "file" + File.separator;
						//url += "\\"+fileName;
				        //String url = sc.getRealPath("/") + File.separator + "auto" + File.separator + "file" + File.separator;
						File file = new File(url);
						if ( ! (file.exists())  &&   ! (file.isDirectory()))  {
			                 boolean  creadok  =  file.mkdirs();
			                 if (creadok)  {
			                    System.out.println( " ok:创建文件夹成功！ " );
			                } else  {
			                    System.out.println( " err:创建文件夹失败！ " );                    
			                } 
			            } 
						String address = url + "/" + getUploadfileFileName().get(i);
						FileOutputStream fos = new FileOutputStream(address); 
						FileInputStream fis = new FileInputStream(files.get(i).toString()); 
						byte[] buffer = new byte[1024]; 
						int len = 0; 
						while ((len = fis.read(buffer)) > 0) 
						{ 
							fos.write(buffer, 0, len);
						} 
						fos.close();
						fis.close();
					}
				}
			}
			
			String flowtaskinfoid = getRequest().getParameter("flowtaskinfoid");
			String flowid = getRequest().getParameter("flowid");
			String flowname = getRequest().getParameter("flowname");
			String taskid = getRequest().getParameter("taskId");
			
			
			String stepid = getRequest().getParameter("steptype");
			FlowTask flowTask = codeReviewService.getFlowTaskById(Long.parseLong(taskid));
			String path = this.getPath(flowid);
			TotalFlowXmlTool fxs = new TotalFlowXmlTool(path);
			Flowstate flowstate = fxs.GetFlowBeginState();
			String formid = flowstate.getForm().split(",")[0];
			List<Flowstate> formidlist = fxs.GetFormlists();
			String stateid = flowstate.getStateid();

			
			flowTask.setFlowName(flowname);
			//===================================保存实例 START=======================================
			
			//取得字段类型是文件的元素
			List fileColumnList = new ArrayList();
			List checkBoxList = new ArrayList();
			List<AutoFormsField> fieldList = autoFormService.getAutoFormsFieldByformid(formid);
			for(int i = 0; i<fieldList.size();i++){
				AutoFormsField aff = fieldList.get(i);
				if("13".equals(aff.getPageDisplayType().toString())){
					fileColumnList.add(aff.getFieldName());
				}else if("5".equals(aff.getPageDisplayType().toString())){
					checkBoxList.add(aff.getFieldName());
				}
			}
			
			String columns = getRequest().getParameter("columns");//页面所有的列
			//查询表单信息
			Flowstate flowstate1 = fxs.GetFlowStateByID(stateid);
			AutoFormsNew formnew =  autoFormService.getAutoFormsNewById(flowstate1.getForm().split(",")[0]);
			//String bsql = "ID,";//拼接sql语句
			String asql = "SEQ_"+formnew.getFormEnName()+".nextval,";
			String updateValues = "";
			String updateSql = "";
			int fileNameIndex = 0;
			if(columns != null){
				String[] columnss = columns.split(",");
				for(String column : columnss){
					String columnValue = "";
					if(fileColumnList.contains(column)){
						if(uploadfileFileName != null && !"".equals(uploadfileFileName.get(fileNameIndex))){
							columnValue = uploadfileFileName.get(fileNameIndex).toString();
							fileNameIndex++;
						}else{
							columnValue = getRequest().getParameter(column);
						}
					}else  if(checkBoxList.contains(column)){//如果是复选框
						String[] values = getRequest().getParameterValues(column);
						columnValue=org.apache.commons.lang.StringUtils.join(values,",");
					}else{
						columnValue = getRequest().getParameter(column);
					}
					//String columnValue = getRequest().getParameter(column);
					if(columnValue == null){
						asql += "'',";
					}else{
						asql += "'" + columnValue +"',";
					}
					updateValues += column+"='"+columnValue+"',";
				}
				//String sql = "insert into "+formnew.getFormEnName()+"("+columns.substring(0,columns.length()-1)+")values("+asql.substring(0,asql.length()-1)+")";
				updateSql = "update "+ formnew.getFormEnName()+" t set " +updateValues.substring(0,updateValues.length()-1) +" where t.ID = '"+flowTask.getMainId()+"'";
				autoService.executeSql(updateSql);
			}
			//===================================保存实例 END=======================================

			XmlHelper xmlhelper = new XmlHelper();
			if("submit".equals(flag)){
				flowTask.setFlowStateId(flowstate.getStateid());
				flowTask.setFlowStateName(flowstate.getState());
				if (!flowstate.getRoleIds().equals(""))
				{
					flowTask.setNextRolesId(","+flowstate.getRoleIds()+",");
				}else{
					flowTask.setNextRolesId("");
				}
				flowTask.setNextRolesName(flowstate.getRoleNames());
				if (!flowstate.getUserIds().equals(""))
				{
					flowTask.setNextUsersId(","+flowstate.getUserIds()+",");
				}else{
					flowTask.setNextUsersId("");
				}
				flowTask.setNextUsersName(flowstate.getUserNames());
				flowTask.setNextDept(flowstate.getDept());
				flowTask.setNextDeptid(flowstate.getDeptid());
				String plantaskname = this.getRequest().getParameter("plantaskname");

				
			}
			codeReviewService.updateFlowTask(flowTask);
			
			out.print("{\"result\":\"success\",\"taskid\":\""+flowTask.getId()+"\"}");
		}catch(Exception exp){
			exp.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}
	public void saveFlowDetail(String taskid,String flowid,Flowstate beforflowstate,Flowstate flowstate,String actiontype,String actiondescript){
		FlowDetailed flowdetail = new FlowDetailed();
		flowdetail.setFlowTaskId(Long.parseLong(taskid));
		flowdetail.setInstanceid(Long.parseLong(taskid));
		flowdetail.setFlowTypeId(Long.parseLong(flowid));
		String userId = ServletActionContext.getRequest().getSession().getAttribute("TDM_USER_ID").toString();
		String userNm = ServletActionContext.getRequest().getSession().getAttribute("username").toString();
		flowdetail.setOperatorperson(userNm);
		flowdetail.setOperatorpersonId(Long.parseLong(userId));
		flowdetail.setStatusbeforeid(beforflowstate.getStateid());
		flowdetail.setStatusbefore(beforflowstate.getState());
		flowdetail.setStatusafterid(flowstate.getStateid());
		flowdetail.setDeptid(Long.parseLong(this.getDeptid()));
		flowdetail.setStatusafter(flowstate.getState());
		flowdetail.setOperatortime(new Timestamp(System.currentTimeMillis()));
		flowdetail.setActiontype(actiontype);
		flowdetail.setActiondescript(actiondescript);
		if(null!=flowstate.getRoleIds() && !"".equals(flowstate.getRoleIds())){
			flowdetail.setNextRoleId(flowstate.getRoleIds());
		}
		if(null!=flowstate.getUserIds()&&!"".equals(flowstate.getUserIds())){
			flowdetail.setNextUserId(flowstate.getUserIds());
		}
		codeReviewService.saveFlowDetailed(flowdetail);
	}
	
	/**
	 * 
	 * 描述：提交流程
	 * @author wangxd
	 * @date Jul 10, 2015 10:11:55 AM
	 * @return void
	 * @throw
	 */
	public void tiJiaoFormData() throws IOException{
		PrintWriter out = this.getResponse().getWriter();
		try {
			String id = getRequest().getParameter("id");
			String flowid = getRequest().getParameter("flowid");
		    String columnNames = getRequest().getParameter("columnNames");
			
			String path = this.getPath(flowid);
			TotalFlowXmlTool fxs = new TotalFlowXmlTool(path);
			Flowstate flowstate = fxs.GetFlowBeginToNextOneState();
			
		    String[] allIds = id.split(",");
		    for(int i=0;i<allIds.length;i++){
		    	String  flowtaskId = allIds[i].toString();
		    	FlowTask flowTask = codeReviewService.getFlowTaskById(Long.parseLong(flowtaskId));
		    	
		    	String flowtaskinfoid = "";
		    	String querySql1 = "select t.id from flow_task_info t where t.flow_task_id =  "+flowtaskId;
		    	List list = autoFormService.getDatabySql(querySql1);
		    	if(null!=list&&list.size()>0&&null!=list.get(0)){
		    		flowtaskinfoid = list.get(0).toString();
		    	}
		    	FlowTaskInfo flowTaskInfo = codeReviewService.getFlowTaskInfoById(Long.parseLong(flowtaskinfoid));
		    	
		    	Flowstate beforflowstate = fxs.GetFlowStateByID(flowTask.getFlowStateId());
				
				flowTask.setId(Long.parseLong(flowtaskId));
				flowTask.setState(0l);
				//flowTask.setWhetherjj("一般");
				flowTask.setFlowStateName(flowstate.getState());
				flowTask.setFlowStateId(flowstate.getStateid());
				
				//常规检测流程下一操作人是批准人
				if(PubMethod.GetFlowid("flow.changguiFlowId").equals(flowid)){
					
					String mainId = flowTask.getMainId().toString();
					String pizhunName="";
					String pizhurenId = getRequest().getParameter("T_PIZHUNREN");
					String userSql = " select t.username  from sys_users t where t.userid= "+pizhurenId;
					List userNameList = autoService.getDatabySql(userSql);
					if(null!=userNameList&&userNameList.size()>0&&null!=userNameList.get(0)){
						pizhunName = userNameList.get(0).toString();
					}
					flowTask.setNextUsersId(","+pizhurenId+",");
					flowTask.setNextUsersName(pizhunName);
					
					flowTaskInfo.setNextUsersId(","+pizhurenId+",");
					flowTaskInfo.setNextUsersName(pizhunName);
					
					//修改实体表
					if(!"".equals(columnNames)){
						String ziduanvalue = "";
						String[] allColumnNames = columnNames.split(",");
						for(int j=0;j<allColumnNames.length;j++){
							String values = getRequest().getParameter(allColumnNames[j]);
							ziduanvalue = ziduanvalue+","+allColumnNames[j]+"='"+values+"'";
						}
						if(!"".equals(ziduanvalue)){
							ziduanvalue = ziduanvalue.substring(1);
							String updateSql = "update "+flowTask.getTablename()+" set " +ziduanvalue +" where id = "+mainId;
							autoFormService.executeBySql(updateSql);
						}
					}
				}if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid)){
					String mainId = flowTask.getMainId().toString();
					String pizhunName="";
					String pizhurenId = getRequest().getParameter("PIZHUNRENYUAN");
					String userSql = " select t.username  from sys_users t where t.userid= "+pizhurenId;
					List userNameList = autoService.getDatabySql(userSql);
					if(null!=userNameList&&userNameList.size()>0&&null!=userNameList.get(0)){
						pizhunName = userNameList.get(0).toString();
					}
					flowTask.setNextUsersId(","+pizhurenId+",");
					flowTask.setNextUsersName(pizhunName);
					
					flowTaskInfo.setNextUsersId(","+pizhurenId+",");
					flowTaskInfo.setNextUsersName(pizhunName);
					
					//修改实体表
					if(!"".equals(columnNames)){
						String ziduanvalue = "";
						String[] allColumnNames = columnNames.split(",");
						for(int j=0;j<allColumnNames.length;j++){
							String values = getRequest().getParameter(allColumnNames[j]);
							ziduanvalue = ziduanvalue+","+allColumnNames[j]+"='"+values+"'";
						}
						if(!"".equals(ziduanvalue)){
							ziduanvalue = ziduanvalue.substring(1);
							String updateSql = "update "+flowTask.getTablename()+" set " +ziduanvalue +" where id = "+mainId;
							autoFormService.executeBySql(updateSql);
						}
					}
				}else{
					if (null!=flowstate.getRoleIds()&&!flowstate.getRoleIds().equals(""))
					{
						flowTask.setNextRolesId(","+flowstate.getRoleIds()+",");
					}else{
						flowTask.setNextRolesId("");
					}
					flowTask.setNextRolesName(flowstate.getRoleNames());
					if (null!=flowstate.getUserIds()&&!flowstate.getUserIds().equals(""))
					{
						flowTask.setNextUsersId(","+flowstate.getUserIds()+",");
					}else{
						flowTask.setNextUsersId("");
					}
					flowTask.setNextUsersName(flowstate.getUserNames());
				}
				flowTask.setNextDept(flowstate.getDept());
				flowTask.setNextDeptid(flowstate.getDeptid());
				
				
				flowTaskInfo.setFlowStateId(flowstate.getStateid());
				flowTaskInfo.setFlowStateName(flowstate.getState());
			
				flowTaskInfo.setNextUsersName(flowstate.getUserNames());
				flowTaskInfo.setNextDept(flowstate.getDept());
				flowTaskInfo.setNextDeptid(flowstate.getDeptid());
				
				codeReviewService.updateFlowTaskInfo(flowTaskInfo);
				
				codeReviewService.updateFlowTask(flowTask);
				
				
				//保存操作明细
				saveFlowDetail(flowtaskId,flowid,beforflowstate,flowstate,"流程操作","");
		    }
			out.print("{\"result\":\"success\"}");
			out.flush();
		} catch (Exception e) {
			out.print("{\"result\":\"error\"}");
		}
	}
	
	/**
	 * 保存数据
	 * @throws Exception
	 */
	public void saveFormData() throws Exception{
		PrintWriter out = this.getResponse().getWriter();
		String flag = getRequest().getParameter("flag");
		String roleid = getRequest().getParameter("roleid");
		String userid = getRequest().getParameter("userid");
		String taskid = getRequest().getParameter("taskId");
		String itemId = getRequest().getParameter("itemId");
		String backoption =getRequest().getParameter("backoption");
		String backstate =getRequest().getParameter("backstate");
		String flowid = getRequest().getParameter("flowid");
		String stateid = getRequest().getParameter("stateid");
		String stepid = getRequest().getParameter("steptype");
		String taskinfoid = getRequest().getParameter("flowtaskinfoid");  //子流程Id
		String gridids = getRequest().getParameter("gridids");  //常规检测流程 --》编辑报告节点 列表id
		String spyj = getRequest().getParameter("spyj");  //审批意见
		FlowTask flowTask = codeReviewService.getFlowTaskById(Long.parseLong(taskid));
		flowTask.setSpyj(spyj);
		
		String path = this.getPath(flowid);
		TotalFlowXmlTool fxs = new TotalFlowXmlTool(path);
		String actionType = "";
		String userId = ServletActionContext.getRequest().getSession().getAttribute("TDM_USER_ID").toString();
		String userNm = ServletActionContext.getRequest().getSession().getAttribute("username").toString();
		Timestamp time = new Timestamp(System.currentTimeMillis());
		//操作类型：顺序，打回
		if(null != stepid){
			  actionType = fxs.GetActionTypeByStepID(stepid);
		}
		try{
			
			//存文件
			List files = getUploadfile();
			if (files!=null)
			{
				for (int i = 0 ; i < files.size() ; i++) 
				{ 
					String fileName = (String) getUploadfileFileName().get(i);
					String fileType = fileName.substring((fileName.lastIndexOf("."))+1, fileName.length());
					File ff = new File(files.get(i).toString());
					if(ff.length()>0)
					{
						ActionContext ac = ActionContext.getContext();
				        ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
				        String url = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();
						File file = new File(url);
						if ( ! (file.exists())  &&   ! (file.isDirectory()))  {
			                 boolean  creadok  =  file.mkdirs();
			                 if (creadok)  {
			                    System.out.println( " ok:创建文件夹成功！ " );
			                } else  {
			                    System.out.println( " err:创建文件夹失败！ " );                    
			                } 
			            } 
						String address = url + "/" + getUploadfileFileName().get(i);
						FileOutputStream fos = new FileOutputStream(address); 
						FileInputStream fis = new FileInputStream(files.get(i).toString()); 
						byte[] buffer = new byte[1024]; 
						int len = 0; 
						while ((len = fis.read(buffer)) > 0) 
						{ 
							fos.write(buffer, 0, len);
						} 
						fos.close();
						fis.close();
					}
				}
			}
			
			String flowtaskinfoid = getRequest().getParameter("flowtaskinfoid");
			
			
			Flowstate flowstate = fxs.GetNextState(stepid);
			Flowstate beforflowstate = fxs.GetFlowStateByID(stateid);
			String formid = beforflowstate.getForm().split(",")[0];
			List<Flowstate> formidlist = fxs.GetFormlists();
			
			//===================================保存实例 START=======================================
			//取得字段类型是文件的元素
			List fileColumnList = new ArrayList();
			List<AutoFormsField> fieldList = autoFormService.getAutoFormsFieldByformid(formid);
			for(int i = 0; i<fieldList.size();i++){
				AutoFormsField aff = fieldList.get(i);
				if("13".equals(aff.getPageDisplayType().toString())){
					fileColumnList.add(aff.getFieldName());
				}
			}
			String columns = getRequest().getParameter("columns");//页面所有的列
			//查询表单信息
			Flowstate flowstate1 = fxs.GetFlowStateByID(stateid);
			AutoFormsNew formnew =  autoFormService.getAutoFormsNewById(flowstate1.getForm().split(",")[0]);
			//String bsql = "ID,";//拼接sql语句
			String asql = "SEQ_"+formnew.getFormEnName()+".nextval,";
			String updateValues = "";
			String updateSql = "";
			int fileNameIndex = 0;
			if(columns != null){
				String[] columnss = columns.split(",");
				for(String column : columnss){
					String columnValue = "";
					if(fileColumnList.contains(column)){
						if(uploadfileFileName != null && !"".equals(uploadfileFileName.get(fileNameIndex))){
							columnValue = uploadfileFileName.get(fileNameIndex).toString();
							fileNameIndex++;
						}else{
							columnValue = getRequest().getParameter(column);
						}
					}else{
						columnValue = getRequest().getParameter(column);
					}
					if(columnValue == null){
						asql += "'',";
						updateValues += column+"='',";
					}else{
						columnValue = columnValue.replace("'", "''");
						asql += "'" + columnValue +"',";
						updateValues += column+"='"+columnValue+"',";
					}
				}
				updateSql = "update "+ formnew.getFormEnName()+" t set " +updateValues.substring(0,updateValues.length()-1) +" where t.ID = '"+flowTask.getMainId()+"'";
				autoService.executeSql(updateSql);
			}
			//===================================保存实例 END=======================================

			XmlHelper xmlhelper = new XmlHelper();
			if("submit".equals(flag)){
				
				FlowTaskInfo flowTaskInfo = codeReviewService.getFlowTaskInfoById(Long.parseLong(flowtaskinfoid));
				//修改  flowTaskInfo表
				flowTaskInfo.setFlowStateId(flowstate.getStateid());
				flowTaskInfo.setFlowStateName(flowstate.getState());
				
				if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))){
					if("shwtd".equals(stateid)&&"step3".equals(stepid)||("ddshwtd".equals(stateid)&&("step5".equals(stepid)||"step6".equals(stepid)))||("bgbz".equals(stateid)&&"step15".equals(stepid))||("bgsh".equals(stateid)&&"step17".equals(stepid))||("bgpz".equals(stateid)&&"step19".equals(stepid))||("bgqz".equals(stateid)&&"step23".equals(stepid))){
						flowTask.setBackstate(0l);
						flowTask.setBackoption(backoption);
						flowTaskInfo.setBackstate(0l);
						flowTaskInfo.setBackoption(backoption);
					}
					else{
						flowTask.setBackstate(1l);
						flowTaskInfo.setBackstate(1l);
					}
				}
				//首先把流程置成不可强制收回
				flowTaskInfo.setIslahui(0l);
				//是角色选人 1 是 0 否 
				
				//常规检测流程--填写委托单提交  
				if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"gcbz".equals(stateid)){
					String pizhunName="";
		            String pizhurenId = getRequest().getParameter("T_PIZHUNREN");
		            String userSql = " select t.username  from sys_users t where t.userid= "+pizhurenId;
		            List userNameList = autoService.getDatabySql(userSql);
		            if(null!=userNameList&&userNameList.size()>0&&null!=userNameList.get(0)){
		              pizhunName = userNameList.get(0).toString();
		            }
		        	flowTask.setNextUsersId(","+pizhurenId+",");
		        	flowTask.setNextUsersName(pizhunName);
		        	
					flowTaskInfo.setNextUsersName(pizhunName);
					flowTaskInfo.setNextUsersId(","+pizhurenId+",");
					flowTaskInfo.setIslahui(1l);
					flowTaskInfo.setLahuistateid(beforflowstate.getStateid());
					flowTaskInfo.setLahuistatename(beforflowstate.getState());
					flowTaskInfo.setChulirenid(","+getUserId()+",");
					flowTaskInfo.setChulirenname(getUserNM());
				}
				
				//常规检测流程--审核委托单提交  下一操作人是提交流程时选的接收方代表
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"shwtd".equals(stateid)&&"step2".equals(stepid)){
					
					String queryNextUserSql =" select  t.t_jieshoudaibiao  from gwm_changgijiance t where t.id = "+flowTask.getMainId();
				    List queryNextUserList = autoService.getDatabySql(queryNextUserSql);
				    if(null!=queryNextUserList&&queryNextUserList.size()>0&&null!=queryNextUserList.get(0)){
				    	String nextUserId = queryNextUserList.get(0).toString();
				    	String userSql = " select t.username  from sys_users t where t.userid= "+nextUserId;
						List userList = autoService.getDatabySql(userSql);
						flowTask.setNextUsersId(","+nextUserId+",");
						flowTaskInfo.setNextUsersId(","+nextUserId+",");
						if(null!=userList&&userList.size()>0&&null!=userList.get(0)){
							flowTask.setNextUsersName(userList.get(0).toString());
							flowTaskInfo.setNextUsersName(userList.get(0).toString());
						}
				    }
				}
				//常规检测流程 ---》调度审核委托单提交
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&("ddshwtd".equals(stateid)&&"step4".equals(stepid))){
					String queryNextUserSql =" select distinct t.t_deptid,t.t_deptname,t.t_deptleaderid,t.t_deptleadername  from gwm_item_sample t where t.t_taskid="+taskid;
				    List queryNextUserList = autoService.getDatabySql(queryNextUserSql);
				    if(null!=queryNextUserList&&queryNextUserList.size()>0&&null!=queryNextUserList.get(0)){
				    	Object[] objects = (Object[])queryNextUserList.get(0);
				    	flowTask.setNextDeptid(objects[0]!=null?objects[0].toString():"");
				    	flowTask.setNextDept(objects[1]!=null?objects[1].toString():"");
						flowTask.setNextUsersId(","+objects[2]+",");
						flowTask.setNextUsersName(","+objects[3]+",");
						flowTask.setNextRolesName("");
						flowTask.setNextRolesId("");
						
						flowTaskInfo.setNextDeptid(objects[0]!=null?objects[0].toString():"");
						flowTaskInfo.setNextDept(objects[1]!=null?objects[1].toString():"");
						flowTaskInfo.setNextUsersId(","+objects[2]+",");
						flowTaskInfo.setNextUsersName(","+objects[3]+",");
						flowTaskInfo.setNextRolesName("");
						flowTaskInfo.setNextRolesId("");
						flowTaskInfo.setSpyj(flowTask.getSpyj());
						flowTaskInfo.setBackoption(flowTask.getBackoption());
						flowTaskInfo.setBackstate(flowTask.getBackstate());
						
						//调度分配项目  如果分配给多个科室领导  则产生多条数据
						if(queryNextUserList.size()>1){
							for(int i=1;i<queryNextUserList.size();i++){
								Object[] obj = (Object[])queryNextUserList.get(i);
								String deptId = obj[0]!=null?obj[0].toString():"";
								String deptleaderid = obj[2]!=null?obj[2].toString():"";
								FlowTaskInfo newflowTaskInfo = new FlowTaskInfo();
								
								newflowTaskInfo.setNextRolesName("");
								newflowTaskInfo.setNextRolesId("");
								newflowTaskInfo.setNextUsersId(","+deptleaderid+",");
								newflowTaskInfo.setNextUsersName(","+obj[3]+",");
								newflowTaskInfo.setNextDept(obj[1]!=null?obj[1].toString():"");
								newflowTaskInfo.setNextDeptid(deptId);
								newflowTaskInfo.setFlowtaskid(flowTaskInfo.getFlowtaskid());
								newflowTaskInfo.setState(flowTaskInfo.getState());
								newflowTaskInfo.setFlowStateId(flowstate.getStateid());
								newflowTaskInfo.setFlowStateName(flowstate.getState());
								
								codeReviewService.saveFlowTaskInfo(newflowTaskInfo);
								
								//修改gwm_item_sample中的T_TASKINFOID的值
								String updateChildTaskId = " update gwm_item_sample t set  t_taskinfoid = "+newflowTaskInfo.getId()+"  where t.t_deptid= "+deptId+" and t.t_deptleaderid="+deptleaderid+" and t.t_taskid="+taskid+" and t.t_taskinfoid="+taskinfoid;
							    autoFormService.executeBySql(updateChildTaskId);
							}
						}
						
				    }
				    //添加样品管理信息  
				    
				    String queryMainSql="select t.t_weituodanbh,t.t_testname,t.t_shenqingdw,t.t_weituoren,t.t_shenqingrq,t.t_telephone from gwm_changgijiance t where t.id ="+flowTask.getMainId();
				    List mainList = autoFormService.getDatabySql(queryMainSql);
				    if(null!=mainList&&mainList.size()>0&&null!=mainList.get(0)){
				    		Object[] objects = (Object[])mainList.get(0);
				    		String weituodanbh = objects[0]!=null?objects[0].toString():"";    //委托单识别号
				    		String testname = objects[1]!=null?objects[1].toString():"";       //任务名称
				    		String shenqingdw =  objects[2]!=null?objects[2].toString():"";    //申请单位
				    		String weituorenId =  objects[3]!=null?objects[3].toString():"";   //委托人ID
				    		String shenqingrq =  objects[4]!=null?objects[4].toString():"";    //申请日期
				    		String telephone = objects[5]!=null?objects[5].toString():"";    //联系电话
				    		
				    		//如果样品管理中存在数据则不添加
						    String querySql = "select t.id from gwm_sample_manage t where t.t_weituohao='"+weituodanbh+"' and t.t_taskid="+taskid;
						    List list = autoFormService.getDatabySql(querySql);
						    if(null==list||list.size()==0){
						    	
						    	String samplemanageSql = "insert into gwm_sample_manage  (id, t_weituohao, t_taskname, t_weituodanw, t_weituoren, t_shenqingrq, t_telephone,t_taskid) " +
				                                         " values (SEQ_GWM_SAMPLE_MANAGE.NEXTVAL,'"+weituodanbh+"','"+testname+"','"+shenqingdw+"','"+weituorenId+"','"+shenqingrq+"','"+telephone+"',"+taskid+")";
		                        autoFormService.executeSql(samplemanageSql);
						    }
				    		
				    }
				    
				}
				//常规检测流程 ---》调度审核委托单提交---委外试验
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&("ddshwtd".equals(stateid)&&"step24".equals(stepid))){
					//修改gwm_item_sample中的T_TASKINFOID的值
					String updateCGJCSql = " update GWM_CHANGGIJIANCE t set  t.isweiwai = '是'  where t.id ="+flowTask.getMainId();
				    autoFormService.executeBySql(updateCGJCSql);
				}
				//常规检测流程 ---》科室任务分配
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"ksrwfp".equals(stateid)&&"step7".equals(stepid)){
					String nextUserName ="";
					String nextUserId ="";
					String queryNextUserSql =" select distinct t.t_jianceyuanid,t.t_jianceyuanname  from gwm_item_sample t where t.t_taskid = "+taskid+" and t.t_deptleaderid="+this.getUserId()+" and t.t_taskinfoid="+taskinfoid;
				    List queryNextUserList = autoService.getDatabySql(queryNextUserSql);
				    if(null!=queryNextUserList&&queryNextUserList.size()>0&&null!=queryNextUserList.get(0)){
				    	Object[] obj = (Object[])queryNextUserList.get(0);
				    	if(null!=obj[0]){
				    		nextUserId = obj[0].toString();
				    	}
				    	if(null!=obj[1]){
				    		nextUserName = obj[1].toString();
				    	}
				    }
					
					flowTask.setNextUsersId(nextUserId);
					flowTask.setNextUsersName(","+nextUserName+",");
					flowTask.setNextDept("");
					flowTask.setNextDeptid("");
					flowTask.setNextRolesId("");
					flowTask.setNextRolesName("");
					
					flowTaskInfo.setNextUsersId(nextUserId);
					flowTaskInfo.setNextUsersName(","+nextUserName+",");
					flowTaskInfo.setNextDept("");
					flowTaskInfo.setNextDeptid("");
					flowTaskInfo.setNextRolesId("");
					flowTaskInfo.setNextRolesName("");
					
					//科室分配不同的人产生多条任务
					if(queryNextUserList.size()>1){
						for(int i=1;i<queryNextUserList.size();i++){
							Object[] obj = (Object[])queryNextUserList.get(i);
							FlowTaskInfo newflowTaskInfo = new FlowTaskInfo();
							
							newflowTaskInfo.setNextRolesName("");
							newflowTaskInfo.setNextRolesId("");
							newflowTaskInfo.setNextUsersId(obj[0]+"");
							newflowTaskInfo.setNextUsersName(","+obj[1]+",");
							newflowTaskInfo.setNextDept("");
							newflowTaskInfo.setNextDeptid("");
							newflowTaskInfo.setFlowtaskid(flowTaskInfo.getFlowtaskid());
							newflowTaskInfo.setState(flowTaskInfo.getState());
							newflowTaskInfo.setFlowStateId(flowstate.getStateid());
							newflowTaskInfo.setFlowStateName(flowstate.getState());
							codeReviewService.saveFlowTaskInfo(newflowTaskInfo);
							String updateItemSempl = " update GWM_ITEM_SAMPLE t set  t.t_taskinfoid = '"+newflowTaskInfo.getId()+"'  where t.t_taskid = "+taskid+" and t.t_jianceyuanid ='"+obj[0]+"' and t.t_taskinfoid="+taskinfoid;
							autoService.executeSql(updateItemSempl);
						}
					}
				}
				//常规检测流程 ---》试验任务接收  下一操作人不变
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"syrwjs".equals(stateid)&&"step9".equals(stepid)){
					
				}
				//常规检测流程 ----》填写原始记录节点  检测项目的报告为出具原始记录(提交后到审核原始记录)、出具检测报告(提交后到报告编制)
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"txysjl".equals(stateid)){
					
					String gwmItemSampleIds = "";
					//查询该流程对应的gwm_item_sample的id
					String queryGItemSamIdsSql = " select wmsys.wm_concat(t.id) from gwm_item_sample t where t.t_taskinfoid= "+taskinfoid;
					List queryGtemSamIdsList = autoFormService.getDatabySql(queryGItemSamIdsSql);
					if(null!=queryGtemSamIdsList&&queryGtemSamIdsList.size()>0&&null!=queryGtemSamIdsList.get(0)){
						gwmItemSampleIds = queryGtemSamIdsList.get(0).toString();
					}
				    String nextUserId = "";
					String ysjlshr = getRequest().getParameter("T_YSJLSHR");
				    String bgbianzhiren = getRequest().getParameter("T_BGBIANZHIREN");
				    String bgtypeSql = "select  distinct i.t_baogaotype from gwm_item_sample t  left join gwm_item_flow i on t.t_itemid =i.id   where   t.t_taskinfoid = '"+taskinfoid+"' ";
				    List bgtypeList = autoFormService.getDatabySql(bgtypeSql);
				    if(null!=bgtypeList&&bgtypeList.size()>0&&null!=bgtypeList.get(0)){
				    	for(int i=0;i<bgtypeList.size();i++){
				    		String bgtype = bgtypeList.get(i).toString();
				    		String nextusername = "";
					    	if("出具原始记录".equals(bgtype)){
					    		stepid = "step12";
					    		nextUserId = ysjlshr;
					    	}
					    	else if("出具检测报告".equals(bgtype)){
					    		stepid = "step11";
					    		nextUserId = bgbianzhiren;
					    	}
					    	String userSql = " select wmsys.wm_concat(to_char(t.username)) from sys_users t where t.userid in ( "+nextUserId+")";
							List userList = autoService.getDatabySql(userSql);
							if(null!=userList&&userList.size()>0&&null!=userList.get(0)){
								nextusername = userList.get(0).toString();
							}
					    	actionType = fxs.GetActionTypeByStepID(stepid);
					    	flowstate = fxs.GetNextState(stepid);
					    	beforflowstate = fxs.GetFlowStateByID(stateid);
					    	formid = beforflowstate.getForm().split(",")[0];
					    	if(i==0){
					    		flowTask.setNextDeptid("");
						    	flowTask.setNextDept("");
								flowTask.setNextUsersId(","+nextUserId+",");
								flowTask.setNextUsersName(","+nextusername+",");
								flowTask.setNextRolesName("");
								flowTask.setNextRolesId("");
								
								flowTaskInfo.setNextDeptid("");
								flowTaskInfo.setNextDept("");
								flowTaskInfo.setNextUsersId(","+nextUserId+",");
								flowTaskInfo.setNextUsersName(","+nextusername+",");
								flowTaskInfo.setNextRolesName("");
								flowTaskInfo.setNextRolesId("");
								flowTaskInfo.setSpyj(flowTask.getSpyj());
								flowTaskInfo.setBackoption(flowTask.getBackoption());
								flowTaskInfo.setBackstate(flowTask.getBackstate());
								
								flowTaskInfo.setNextDept(flowstate.getDept());
								flowTaskInfo.setNextDeptid(flowstate.getDeptid());
								flowTaskInfo.setFlowStateId(flowstate.getStateid());
								flowTaskInfo.setFlowStateName(flowstate.getState());
									
					    	}else{
								FlowTaskInfo newflowTaskInfo = new FlowTaskInfo();
								
								newflowTaskInfo.setNextRolesName("");
								newflowTaskInfo.setNextRolesId("");
								newflowTaskInfo.setNextUsersId(","+nextUserId+",");
								newflowTaskInfo.setNextUsersName(","+nextusername+",");
								newflowTaskInfo.setNextDept("");
								newflowTaskInfo.setNextDeptid("");
								newflowTaskInfo.setFlowtaskid(flowTaskInfo.getFlowtaskid());
								newflowTaskInfo.setState(flowTaskInfo.getState());
								newflowTaskInfo.setFlowStateId(flowstate.getStateid());
								newflowTaskInfo.setFlowStateName(flowstate.getState());
								
								codeReviewService.saveFlowTaskInfo(newflowTaskInfo);
								//修改gwm_item_sample中的T_TASKINFOID的值
								String updateChildTaskId = " update gwm_item_sample t set  t.t_taskinfoid = "+newflowTaskInfo.getId()+"  where t.t_taskinfoid ="+taskinfoid+" and t.t_taskid="+taskid+" and t.t_itemid  in (select i.id from gwm_item_flow i where i.t_baogaotype='"+bgtype+"')";
							    autoFormService.executeBySql(updateChildTaskId);
					    	}
				    	}
				   }
				    //提交事修改字段t_sfdianziqianm（是否电子签名）的值为kong
				    String updatesql = "update gwm_item_sample t set t.t_sfdianziqianm= null where t.id in ("+gwmItemSampleIds+")";
				    autoFormService.executeSql(updatesql);
				}
				//常规检测流程--审核原始记录节点提交 
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"shysjl".equals(stateid)){
					if("step14".equals(stepid)){
						String queryNextUserSql =" select  t.t_jieshoudaibiao  from gwm_changgijiance t where t.id = "+flowTask.getMainId();
					    List queryNextUserList = autoService.getDatabySql(queryNextUserSql);
					    if(null!=queryNextUserList&&queryNextUserList.size()>0&&null!=queryNextUserList.get(0)){
					    	String nextUserId = queryNextUserList.get(0).toString();
					    	String userSql = " select t.username  from sys_users t where t.userid= "+nextUserId;
							List userList = autoService.getDatabySql(userSql);
							flowTask.setNextUsersId(","+nextUserId+",");
							flowTaskInfo.setNextUsersId(","+nextUserId+",");
							if(null!=userList&&userList.size()>0&&null!=userList.get(0)){
								flowTask.setNextUsersName(userList.get(0).toString());
								flowTaskInfo.setNextUsersName(userList.get(0).toString());
							}
					    }
					    //如果该任务中其他分支已经到报告与原始记录发放 则此任务的状态为结束  
					    String checkSql = "select t.id  from flow_task_info t where t.flow_state_id='bgysjlff' and t.flow_task_id ="+taskid;
					    List checkList = autoFormService.getDatabySql(checkSql);
					    if(null!=checkList&&checkList.size()>0&&null!=checkList.get(0)){
							flowTaskInfo.setFlowStateId("end");
							flowTaskInfo.setFlowStateName("结束");
					    }
					  //数据库表gwm_item_sample的字段T_REPORTSFTJ 改为1
				    	String updateChildTaskId = " update gwm_item_sample t set  t.T_REPORTSFTJ = 1  where t.t_taskinfoid ="+taskinfoid+" and t.t_taskid="+taskid;
					    autoFormService.executeBySql(updateChildTaskId);
					}else{
						//退回  修改字段t_sfdianziqianm（是否电子签名）的值为kong
						String updateChildTaskId = " update gwm_item_sample t set  t.t_sfdianziqianm = null  where t.t_taskinfoid ="+taskinfoid+" and t.t_taskid="+taskid;
					    autoFormService.executeBySql(updateChildTaskId);
					}
					
				}
				//常规检测流程--报告编制提交  下一操作人是提交流程时选的审核人员
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"bgbz".equals(stateid)){
					
					if("step13".equals(stepid)){
						//只提交列表中已选的数据(未选中的数据的 t_taskinfoid的值修改为flowtaskInfo的Id)
						String querysql1 = "select wmsys.wm_concat(t.id) from gwm_item_sample t  where t.t_taskinfoid ="+taskinfoid+" and t.t_taskid="+taskid+" and  (t.t_bgfilepath is null or t.t_bgfilepath not in (select a.t_bgfilepath from gwm_item_sample a where a.id  in ("+gridids+")))";
						List list1 = autoFormService.getDatabySql(querysql1);
						if(null!=list1&&list1.size()>0&&null!=list1.get(0)){
							FlowTaskInfo newflowTaskInfo = new FlowTaskInfo();
							newflowTaskInfo.setNextRolesName("");
							newflowTaskInfo.setNextRolesId("");
							newflowTaskInfo.setNextUsersId(","+flowTask.getNextUsersId()+",");
							newflowTaskInfo.setNextUsersName(","+flowTask.getNextUsersName()+",");
							newflowTaskInfo.setNextDept("");
							newflowTaskInfo.setNextDeptid("");
							newflowTaskInfo.setFlowtaskid(flowTaskInfo.getFlowtaskid());
							newflowTaskInfo.setState(flowTaskInfo.getState());
							newflowTaskInfo.setFlowStateId("bgbz");
							newflowTaskInfo.setFlowStateName("报告编制");

							codeReviewService.saveFlowTaskInfo(newflowTaskInfo);
							//修改gwm_item_sample中的T_TASKINFOID的值
							String updateChildTaskId = " update gwm_item_sample t set  t.t_taskinfoid = "+newflowTaskInfo.getId()+"  where t.id in ("+list1.get(0)+")";
						    autoFormService.executeBySql(updateChildTaskId);
						}
						else{
							flowTaskInfo.setIslahui(1l);
							flowTaskInfo.setLahuistateid(beforflowstate.getStateid());
							flowTaskInfo.setLahuistatename(beforflowstate.getState());
							flowTaskInfo.setChulirenid(","+getUserId()+",");
							flowTaskInfo.setChulirenname(getUserNM());
						}
						
					    
					    //修改已选中数据的下一操作人
						String queryNextUserSql =" select  t.t_bgshenhe  from gwm_changgijiance t where t.id = "+flowTask.getMainId();
					    List queryNextUserList = autoService.getDatabySql(queryNextUserSql);
					    if(null!=queryNextUserList&&queryNextUserList.size()>0&&null!=queryNextUserList.get(0)){
					    	String nextUserId = queryNextUserList.get(0).toString();
					    	String userSql = " select t.username  from sys_users t where t.userid= "+nextUserId;
							List userList = autoService.getDatabySql(userSql);
							flowTask.setNextUsersId(","+nextUserId+",");
							flowTaskInfo.setNextUsersId(","+nextUserId+",");
							if(null!=userList&&userList.size()>0&&null!=userList.get(0)){
								flowTask.setNextUsersName(userList.get(0).toString());
								flowTaskInfo.setNextUsersName(userList.get(0).toString());
							}
					    }
					  //修改字段T_REPORTSFQIANMING （报告是否签名）为空
					    String updatesfqmSql = "update gwm_item_sample t set  t.t_reportsfqianming = null   where t.t_taskinfoid ="+taskinfoid+" and t.t_taskid="+taskid +" and t.t_bgfilepath  in (select a.t_bgfilepath from gwm_item_sample a where a.id  in ("+gridids+"))";
					    autoFormService.executeSql(updatesfqmSql);
					}
					//退回  修改t_sfdianziqianm的值为null
					else if("step15".equals(stepid)){
						String updateGwmItemSample = " update gwm_item_sample t set  t.t_sfdianziqianm = null,t.t_reportsfqianming=null  where  t.t_taskinfoid ="+taskinfoid+" and t.t_taskid="+taskid;
					    autoFormService.executeBySql(updateGwmItemSample);
					}
					
				    
				    
				}
				//常规检测流程--报告审核提交  下一操作人是报告编制节点选择的批准人员
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"bgsh".equals(stateid)){
					if("step16".equals(stepid)){
						String queryNextUserSql =" select  t.t_bgpizhunuren  from gwm_changgijiance t where t.id = "+flowTask.getMainId();
					    List queryNextUserList = autoService.getDatabySql(queryNextUserSql);
					    if(null!=queryNextUserList&&queryNextUserList.size()>0&&null!=queryNextUserList.get(0)){
					    	String nextUserId = queryNextUserList.get(0).toString();
					    	String userSql = " select t.username  from sys_users t where t.userid= "+nextUserId;
							List userList = autoService.getDatabySql(userSql);
				//			flowTask.setNextUsersId(","+nextUserId+",");
							flowTaskInfo.setNextUsersId(","+nextUserId+",");
							if(null!=userList&&userList.size()>0&&null!=userList.get(0)){
				//				flowTask.setNextUsersName(userList.get(0).toString());
								flowTaskInfo.setNextUsersName(userList.get(0).toString());
							}
					    }
					}
				    
				    //修改字段T_REPORTSFQIANMING （报告是否签名）
				    String updatesfqmSql = "update gwm_item_sample t set  t.t_reportsfqianming = null,t.t_sfdianziqianm =null   where t.t_taskinfoid ="+taskinfoid;
				    autoFormService.executeSql(updatesfqmSql);
			
				}
				//常规检测流程--报告批准节点提交  
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"bgpz".equals(stateid)){
					
					if("step18".equals(stepid)){
						String queryNextUserSql =" select  t.t_jieshoudaibiao  from gwm_changgijiance t where t.id = "+flowTask.getMainId();
					    List queryNextUserList = autoService.getDatabySql(queryNextUserSql);
					    if(null!=queryNextUserList&&queryNextUserList.size()>0&&null!=queryNextUserList.get(0)){
					    	String nextUserId = queryNextUserList.get(0).toString();
					    	String userSql = " select t.username  from sys_users t where t.userid= "+nextUserId;
							List userList = autoService.getDatabySql(userSql);
							flowTask.setNextUsersId(","+nextUserId+",");
							flowTaskInfo.setNextUsersId(","+nextUserId+",");
							if(null!=userList&&userList.size()>0&&null!=userList.get(0)){
								flowTask.setNextUsersName(userList.get(0).toString());
								flowTaskInfo.setNextUsersName(userList.get(0).toString());
							}
					    }
					}
					
				    //修改字段T_REPORTSFQIANMING （报告是否签名）、t_sfdianziqianm（原始记录是否签名）
				    String updatesfqmSql = "update gwm_item_sample t set  t.t_reportsfqianming = null,t.t_sfdianziqianm =null   where t.t_taskinfoid ="+taskinfoid;
				    autoFormService.executeSql(updatesfqmSql);
			
				}
				//常规检测流程--报告签章节点提交  
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"bgqz".equals(stateid)){
					
					if("step20".equals(stepid)){
						String queryNextUserSql =" select  t.t_jieshoudaibiao  from gwm_changgijiance t where t.id = "+flowTask.getMainId();
					    List queryNextUserList = autoService.getDatabySql(queryNextUserSql);
					    if(null!=queryNextUserList&&queryNextUserList.size()>0&&null!=queryNextUserList.get(0)){
					    	String nextUserId = queryNextUserList.get(0).toString();
					    	String userSql = " select t.username  from sys_users t where t.userid= "+nextUserId;
							List userList = autoService.getDatabySql(userSql);
							flowTask.setNextUsersId(","+nextUserId+",");
							flowTaskInfo.setNextUsersId(","+nextUserId+",");
							if(null!=userList&&userList.size()>0&&null!=userList.get(0)){
								flowTask.setNextUsersName(userList.get(0).toString());
								flowTaskInfo.setNextUsersName(userList.get(0).toString());
							}
					    }
					    //如果该任务中其他分支已经到报告与原始记录发放 则此任务的状态为结束  
					    String checkSql = "select t.id  from flow_task_info t where t.flow_state_id='bgysjlff' and t.flow_task_id ="+taskid;
					    List checkList = autoFormService.getDatabySql(checkSql);
					    if(null!=checkList&&checkList.size()>0&&null!=checkList.get(0)){
					    	
							flowTaskInfo.setFlowStateId("end");
							flowTaskInfo.setFlowStateName("结束");
					    }
					    
					  //数据库表gwm_item_sample的字段T_REPORTSFTJ 改为1
				    	String updateChildTaskId = " update gwm_item_sample t set  t.T_REPORTSFTJ = 1  where t.t_taskinfoid ="+taskinfoid+" and t.t_taskid="+taskid;
					    autoFormService.executeBySql(updateChildTaskId);
					}
					
					 //修改字段T_REPORTSFQIANMING （报告是否签名）、t_sfdianziqianm（原始记录是否签名）
				    String updatesfqmSql = "update gwm_item_sample t set  t.t_reportsfqianming = null,t.t_sfdianziqianm =null   where t.t_taskinfoid ="+taskinfoid;
				    autoFormService.executeSql(updatesfqmSql);
			
				 
				}
				//常规检测流程 ---报告与原始记录发放节点提交  默认报告与原始记录全部发放
				else if(flowid.equals(PubMethod.GetFlowid("flow.changguiFlowId"))&&"bgysjlff".equals(stateid)){
					String reportsftjSql = "update gwm_item_sample  t  set   t.t_reportsftj = 0 where t.t_taskid = "+taskid;
					autoFormService.executeSql(reportsftjSql);
				}
				
				else if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "gcbz".equals(stateid)){
					//研发检测流程 填写委托单节点
					String querySql = "select  t.PIZHUNRENYUAN  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
					List pizhunrenList = autoService.getDatabySql(querySql);
					if(null != pizhunrenList && pizhunrenList.size()>0){
						flowTaskInfo.setNextUsersId(","+pizhunrenList.get(0).toString()+",");
					}
					flowTaskInfo.setIslahui(1l);
					flowTaskInfo.setLahuistateid(beforflowstate.getStateid());
					flowTaskInfo.setLahuistatename(beforflowstate.getState());
					flowTaskInfo.setChulirenid(","+getUserId()+",");
					flowTaskInfo.setChulirenname(getUserNM());
				}
				else if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "proc00".equals(stateid)){
					//研发检测流程  委托方审核委托单节点
					if("step2".equals(stepid)){//提交
						String querySql = "select  t.jieshoufangdaibiao  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
						List jieshoufangList = autoService.getDatabySql(querySql);
						if(null != jieshoufangList && jieshoufangList.size()>0){
							flowTaskInfo.setNextUsersId(","+jieshoufangList.get(0).toString()+",");
						}
					}else{//退回给编制人
						String querySql = "select  t.BIANZHIRENYUANID  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
						List weituorenList = autoService.getDatabySql(querySql);
						if(null != weituorenList && weituorenList.size()>0){
							flowTaskInfo.setNextUsersId(","+weituorenList.get(0).toString()+",");
						}
					}
				}else if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "proc0".equals(stateid)){
					//研发检测流程  调度员审核委托单节点
					if("step4".equals(stepid)){//提交
						String nextuserId = getRequest().getParameter("XIANGMUJINGLI");
						flowTaskInfo.setNextUsersId(","+nextuserId+",");
					}else if("step12".equals(stepid)){//退回给委托方审核人
						String querySql = "select  t.PIZHUNRENYUAN  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
						List pizhunrenList = autoService.getDatabySql(querySql);
						if(null != pizhunrenList && pizhunrenList.size()>0){
							flowTaskInfo.setNextUsersId(","+pizhunrenList.get(0).toString()+",");
						}
					}else{//退回给编制人
						String querySql = "select  t.BIANZHIRENYUANID  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
						List weituorenList = autoService.getDatabySql(querySql);
						if(null != weituorenList && weituorenList.size()>0){
							flowTaskInfo.setNextUsersId(","+weituorenList.get(0).toString()+",");
						}
					}
				}else if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "proc1".equals(stateid)){
					//研发检测流程  项目经理分配人员节点
					if("step5".equals(stepid)){//提交
						String jiancerenyuans = getRequest().getParameter("RENWUYUAN");
						flowTaskInfo.setNextUsersId(","+jiancerenyuans+",");
					}else{//退回给调度员
						String querySql = "select  t.jieshoufangdaibiao  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
						List jieshoufangList = autoService.getDatabySql(querySql);
						if(null != jieshoufangList && jieshoufangList.size()>0){
							flowTaskInfo.setNextUsersId(","+jieshoufangList.get(0).toString()+",");
						}
					}
				}else if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "proc2".equals(stateid)){
					//研发检测流程  过程记录节点
					if("step6".equals(stepid)){//提交
						String baogaobianzhiren = getRequest().getParameter("BAOGAOBIANXIEREN");
						flowTaskInfo.setNextUsersId(","+baogaobianzhiren+",");
					}else{//退回给项目经理
						String querySql = "select  t.XIANGMUJINGLI  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
						List xiangmujingliList = autoService.getDatabySql(querySql);
						if(null != xiangmujingliList && xiangmujingliList.size()>0){
							flowTaskInfo.setNextUsersId(","+xiangmujingliList.get(0).toString()+",");
						}
					}
				}else if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "proc3".equals(stateid)){
					//研发检测流程  编制报告节点
					if("step7".equals(stepid)){//提交
						String baogaoshenheren = getRequest().getParameter("T_BGSHENHE");
						flowTaskInfo.setNextUsersId(","+baogaoshenheren+",");
					}else{//退回给任务员
						String querySql = "select  t.RENWUYUAN  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
						List renwuyuanList = autoService.getDatabySql(querySql);
						if(null != renwuyuanList && renwuyuanList.size()>0){
							flowTaskInfo.setNextUsersId(","+renwuyuanList.get(0).toString()+",");
						}
					}
				}else if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "proc4".equals(stateid)){
					//研发检测流程 审核报告节点
					if("step8".equals(stepid)){//提交
						String querySql = "select  t.t_bgpizhunuren  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
						List bgpizhunrenList = autoService.getDatabySql(querySql);
						if(null != bgpizhunrenList && bgpizhunrenList.size()>0){
							flowTaskInfo.setNextUsersId(","+bgpizhunrenList.get(0).toString()+",");
						}
					}else{//退回给报告编写人
						String querySql = "select  t.BAOGAOBIANXIEREN  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
						List baogaobianxierenList = autoService.getDatabySql(querySql);
						if(null != baogaobianxierenList && baogaobianxierenList.size()>0){
							flowTaskInfo.setNextUsersId(","+baogaobianxierenList.get(0).toString()+",");
						}
					}
				}else if(PubMethod.GetFlowid("flow.yanfajianceflowid").equals(flowid) && "proc5".equals(stateid)){
					//研发检测流程 批准报告节点
					if("step9".equals(stepid)){//提交
						String querySql = "select  t.jieshoufangdaibiao  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
						List jieshoufangList = autoService.getDatabySql(querySql);
						if(null != jieshoufangList && jieshoufangList.size()>0){
							flowTaskInfo.setNextUsersId(","+jieshoufangList.get(0).toString()+",");
						}
					}else{//退回给报告审核人
						String querySql = "select  t.T_BGSHENHE  from GWM_YANFAJIANCE t where t.id = "+flowTask.getMainId();
						List baogaoshenherenList = autoService.getDatabySql(querySql);
						if(null != baogaoshenherenList && baogaoshenherenList.size()>0){
							flowTaskInfo.setNextUsersId(","+baogaoshenherenList.get(0).toString()+",");
						}
					}
				}
				else{
					//如果是退回  退回给上一节点的操作人
				   if("打回".equals(actionType)){
					   String uqeryusersql = "select  t.operatorperson_id,t.operatorperson  from flow_detailed t where  t.statusbeforeid ='"+flowstate.getStateid()+"' and t.flow_task_id="+taskid+" order by t.id desc";
				       List quserlist = autoFormService.getDatabySql(uqeryusersql);
				       if(null!=quserlist&&quserlist.size()>0&&null!=quserlist.get(0)){
				    	   Object[] obj = (Object[])quserlist.get(0);
				    	   String nextuserid = obj[0]!=null?obj[0].toString():"";
				    	   String nextusername = obj[1]!=null?obj[1].toString():"";
				    	   flowTask.setNextUsersId(","+nextuserid+",");
				    	   flowTask.setNextUsersName(","+nextusername+",");
				    	   
				    	   flowTaskInfo.setNextUsersId(","+nextuserid+",");
				    	   flowTaskInfo.setNextUsersName(","+nextusername+",");
				       }
				   }
				   else {
					   if(!"".equals(beforflowstate.getIsselectperson())&&beforflowstate.getIsselectperson().equals("1")){
							flowTask.setNextRolesId("");
							flowTask.setNextRolesName("");
							flowTask.setNextUsersId(","+userid+",");
							//更新flowTaskInfo 表
							flowTaskInfo.setNextRolesId("");
							flowTaskInfo.setNextRolesName("");
							flowTaskInfo.setNextUsersId(","+userid+",");
						}else{//不是角色选人
							if (!flowstate.getRoleIds().equals(""))
							{
								flowTask.setNextRolesId(","+flowstate.getRoleIds()+",");
								//更新flowTaskInfo 表
								flowTaskInfo.setNextRolesId(","+flowstate.getRoleIds()+",");
							}else{
								flowTask.setNextRolesId("");
								//更新flowTaskInfo 表
								flowTaskInfo.setNextRolesId("");
							}
							flowTask.setNextRolesName(flowstate.getRoleNames());
							//更新flowTaskInfo 表
							flowTaskInfo.setNextRolesName(flowstate.getRoleNames());
							
							if (!flowstate.getUserIds().equals(""))
							{
								flowTask.setNextUsersId(","+flowstate.getUserIds()+",");
								//更新flowTaskInfo 表
								flowTaskInfo.setNextUsersId(","+flowstate.getUserIds()+",");
							}else{
								flowTask.setNextUsersId("");
								//更新flowTaskInfo 表
								flowTaskInfo.setNextUsersId("");
							}
						}
						flowTask.setNextUsersName(flowstate.getUserNames());
						//更新flowTaskInfo 表
						flowTaskInfo.setNextUsersName(flowstate.getUserNames());
				   }
				}
				
				
				flowTask.setNextDept(flowstate.getDept());
				flowTask.setNextDeptid(flowstate.getDeptid());
				flowTask.setFlowStateId(flowstate.getStateid());
				flowTask.setFlowStateName(flowstate.getState());
				
			
				String nodetype =beforflowstate.getNodetype();
				//保存详细信息
				FlowDetailed flowdetail = new FlowDetailed();
				
				flowdetail.setFlowTaskId(Long.parseLong(taskid));
				flowdetail.setFlowTypeId(flowTask.getFlowTypeId());
				flowdetail.setOperatorperson(userNm);
				flowdetail.setOperatorpersonId(Long.parseLong(userId));
				flowdetail.setStatusbeforeid(beforflowstate.getStateid());
				flowdetail.setStatusbefore(beforflowstate.getState());
				flowdetail.setStatusafterid(flowstate.getStateid());
				flowdetail.setStatusafter(flowstate.getState());
				flowdetail.setDeptid(Long.parseLong(this.getDeptid()));
				flowdetail.setOperatortime(time);
				flowdetail.setActiontype("流程操作");
				flowdetail.setRemark(spyj);
				flowdetail.setChildTaskId(Long.parseLong(taskid));
				
				codeReviewService.saveFlowDetailed(flowdetail);
				
				flowTask.setAddUserId(Long.parseLong(userId));
				flowTask.setAddUserName(userNm);
				flowTask.setAddTime(time);
				
				codeReviewService.updateFlowTask(flowTask);
				
			
				codeReviewService.updateFlowTaskInfo(flowTaskInfo);
				
				
			}
			out.print("{\"result\":\"success\"}");
		
		}catch(Exception exp){
			exp.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}
	/**
	 * 
	 * 描述：查询流程路径
	 * @author wangxd
	 * @date Jul 1, 2015 10:37:08 AM
	 * @return String
	 * @throw
	 */
	public String getPath(String flowid){
		Long ids = Long.parseLong(flowid);//241为流程实例的id
		flowtype = codeReviewService.findFileNameById(ids);
		String filename = flowtype.getFilename();
		String path = PubMethod.GetFlowFilePath()+filename;
		return path;
	}
	
	/**
	 * 删除流程的方法
	 */
	public void removeViewExec() throws IOException{
		PrintWriter out = getResponse().getWriter();
	  	try {
			String ids=getRequest().getParameter("ids");
			String idss[] = ids.split(",");
			for(String id:idss){
				 FlowTask flowTask = autoFormService.getFlowTaskById(Long.parseLong(id));
				 if(null != flowTask.getMainId() && null != flowTask.getTablename() && !"".equals(flowTask.getMainId()) && !"".equals(flowTask.getTablename()) ){
					 autoFormService.deleteFormTable( flowTask.getMainId(),flowTask.getTablename());
				 }
				 if(ids !=null&& !ids.isEmpty()){
					 autoFormService.removeView(id);
				 }
			}
			 out.print("{\"ajaxResult\":\"success\"}");
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
			//logService.saveLogInfo(this.getLogBase(), "", "", "删除失败");
		}
	}
	/**
	 * 
	 * 描述：常规检测流程生成委托单识别号
	 * @author wangxd
	 * @date Jul 13, 2015 4:51:34 PM
	 * @return void
	 * @throws IOException 
	 * @throw
	 */
	public void queryWeituoshibiehao() throws IOException{
		PrintWriter out = getResponse().getWriter();
	  	try {
	  		String flowtaskid = getRequest().getParameter("taskId");
	  		String weituodanshibieno = "";
	  		String shibiehao ="";
			String formId=getRequest().getParameter("formId");
			String sql = "select  j.t_gongsidaima  from gwm_changgijiance t left join gwm_jiancedanwei  j on t.t_jiancedanwei = j.id  where t.id="+formId;
			List list = autoFormService.getDatabySql(sql);
			if(null!=list&&list.size()>0&&null!=list.get(0)){
				//公司代码
				String daima = list.get(0).toString();
				Calendar a=Calendar.getInstance();
				String year = String.valueOf(a.get(Calendar.YEAR));
				year = year.substring(year.length()-2, year.length());
				
				//委托单识别号
				weituodanshibieno = "WT"+year+"-"+daima+"-";
				WebApplicationContext factory = WebApplicationContextUtils.getRequiredWebApplicationContext(getRequest().getSession().getServletContext());  
				WeituodanService weituodanService =  (WeituodanService)factory.getBean("weituodanService");
				List list1 = weituodanService.queryWeituodanShibieno(year);
				if(null != list1 && list1.size()>0){
					if(null != list1.get(0) && !"".equals(list1.get(0))){
						int number = Integer.parseInt(list1.get(0).toString())+1;
						weituodanshibieno = weituodanshibieno + new DecimalFormat("0000").format(number);
					}else{
						weituodanshibieno = weituodanshibieno + "0001";
					}
					String insertSql = "insert into WEITUODAN_SHIBIEHAO (ID,SHIBIEHAO,TASKID) value (SEQ_WORKFLOWDETAIL_ID.nextVal,'"+weituodanshibieno+"','"+flowtaskid+"')";
					autoService.executeSql(insertSql);
				}
//				//年
//				SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
//				String  year = sdf.format(new Date());
//				//查询流水号
//				String lishuihao ="";
//				String liushuihaoSql ="select SEQ_CHANGGUIJIANCE_WEITUODANBH.nextVal from dual";
//				List liushuihaoList = autoFormService.getDatabySql(liushuihaoSql);
//				if(null!=liushuihaoList&&liushuihaoList.size()>0&&null!=liushuihaoList.get(0)){
//					lishuihao = liushuihaoList.get(0).toString();
//					while (lishuihao.length() < 4) {
//						lishuihao = "0" + lishuihao;
//				    }
//				}
//				shibiehao ="WT"+year.substring(2)+"-"+daima+"-"+lishuihao;
			}
			 out.print("{\"ajaxResult\":\""+weituodanshibieno+"\"}");
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	
	public String getChangguijianceShibiehao(String mainId,String flowtaskid){
		String weituodanshibieno =""; //委托单识别号
		//判断识别号是否为空
		String querySql = "select t_weituodanbh from gwm_changgijiance t where t.id = "+mainId;
		List queryList = autoFormService.getDatabySql(querySql);
		if(null!=queryList&&queryList.size()>0&&null!=queryList.get(0)){
			weituodanshibieno = queryList.get(0).toString();
		}else{
			String sql = "select  j.t_gongsidaima  from gwm_changgijiance t left join gwm_jiancedanwei  j on t.t_jiancedanwei = j.id  where t.id="+mainId;
			List list = autoFormService.getDatabySql(sql);
			if(null!=list&&list.size()>0&&null!=list.get(0)){
				//公司代码
				String daima = list.get(0).toString();
				Calendar a=Calendar.getInstance();
				String year = String.valueOf(a.get(Calendar.YEAR));
				year = year.substring(year.length()-2, year.length());
				
				 weituodanshibieno = "WT"+year+"-"+daima+"-";
				WebApplicationContext factory = WebApplicationContextUtils.getRequiredWebApplicationContext(getRequest().getSession().getServletContext());  
				WeituodanService weituodanService =  (WeituodanService)factory.getBean("weituodanService");
				List list1 = weituodanService.queryWeituodanShibieno(year);
				if(null != list1 && list1.size()>0){
					if(null != list1.get(0) && !"".equals(list1.get(0))){
						int number = Integer.parseInt(list1.get(0).toString())+1;
						weituodanshibieno = weituodanshibieno + new DecimalFormat("0000").format(number);
					}else{
						weituodanshibieno = weituodanshibieno + "0001";
					}
					String insertSql = "insert into WEITUODAN_SHIBIEHAO (ID,SHIBIEHAO,TASKID) values (SEQ_WORKFLOWDETAIL_ID.nextVal,'"+weituodanshibieno+"','"+flowtaskid+"')";
					autoService.executeSql(insertSql);
					String updateSql = " update gwm_changgijiance t set t.t_weituodanbh ='"+weituodanshibieno+"'  where t.id = "+mainId;
					autoFormService.executeSql(updateSql);
				}
//			String sql = "select  j.t_gongsidaima  from gwm_changgijiance t left join gwm_jiancedanwei  j on t.t_jiancedanwei = j.id  where t.id="+mainId;
//			List list = autoFormService.getDatabySql(sql);
//			if(null!=list&&list.size()>0&&null!=list.get(0)){
//				//公司代码
//				String daima = list.get(0).toString();
//				//年
//				SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
//				String  year = sdf.format(new Date());
//				//查询流水号
//				String lishuihao ="";
//				String liushuihaoSql ="select SEQ_CHANGGUIJIANCE_WEITUODANBH.nextVal from dual";
//				List liushuihaoList = autoFormService.getDatabySql(liushuihaoSql);
//				if(null!=liushuihaoList&&liushuihaoList.size()>0&&null!=liushuihaoList.get(0)){
//					lishuihao = liushuihaoList.get(0).toString();
//					while (lishuihao.length() < 4) {
//						lishuihao = "0" + lishuihao;
//				    }
//				}
//				shibiehao ="WT"+year.substring(2)+"-"+daima+"-"+lishuihao;
//				//修改GWM_CHANGGIJIANCE
//				String updateSql = " update gwm_changgijiance t set t.t_weituodanbh ='"+shibiehao+"'  where t.id = "+mainId;
//				autoFormService.executeSql(updateSql);
			}
		}
		return weituodanshibieno;
	}

	
	/**
	 * 
	 * 描述：常规检测流程生成样品编号
	 * @author wangxd
	 * @date Jul 14, 2015 11:31:35 AM
	 * @return void
	 * @throw
	 */
	public void shengchengSampleNo() throws IOException{
		PrintWriter out = getResponse().getWriter();
	  	try {
	  		String ids = getRequest().getParameter("ids");
			String shibiehao=getRequest().getParameter("shibiehao");
			codeReviewService.shengchengSampleNo(ids, shibiehao);
			
			out.print("{\"ajaxResult\":\"success\"}");
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	/**
	 * 
	 * 描述：常规检测流程——>调度审核委托单   提交时判断是否分配项目
	 * @author wangxd
	 * @date Jul 15, 2015 11:19:56 AM
	 * @return void
	 * @throw
	 */
	public void checkFenpeiItemSample() throws IOException{
		PrintWriter out = getResponse().getWriter();
	  	try {
	  		String taskId = getRequest().getParameter("taskId");
			String sql = "select t.id from gwm_item_sample t where t.t_taskid = "+taskId;
			List list = autoFormService.getDatabySql(sql);
			if(null!=list&&list.size()>0){
				out.print("{\"ajaxResult\":\"true\"}");
			}else{
				out.print("{\"ajaxResult\":\"false\"}");
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	/*
	 * 判断是否分配试验员
	 * wxj
	 */
	public void  checkShiyanyuanEmpty() throws IOException{
		PrintWriter out = getResponse().getWriter();
	  	try {
	  		String taskId = getRequest().getParameter("taskId");
	  		String taskInfoId = getRequest().getParameter("taskInfoId");
			String sqlJCY = "select count(t.T_JIANCEYUANID) from gwm_item_sample t where t.t_taskid ="+taskId+" and t.t_taskinfoid="+taskInfoId;
			List JCYList = autoFormService.getDatabySql(sqlJCY);
			String sqlJCXM = "select count(t.id) from gwm_item_sample t where t.t_taskid ="+taskId+" and t.t_taskinfoid="+taskInfoId;
			List JCXMList = autoFormService.getDatabySql(sqlJCXM);
			if(null!=JCYList&&JCYList.size()>0&&null!=JCXMList&&JCXMList.size()>0){
				int JCYNum = Integer.parseInt(JCYList.get(0).toString());
				int JCXMNum = Integer.parseInt(JCXMList.get(0).toString());
				if(JCYNum<JCXMNum){
					out.print("{\"ajaxResult\":\"false\"}");
				}else{
					out.print("{\"ajaxResult\":\"true\"}");
				}
			}else{
				out.print("{\"ajaxResult\":\"false\"}");
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	
	/**
	 * 
	 * 描述：常规检测流程---》报告与原始记录发放节点  提交时校验
	 * @author wangxd
	 * @date Aug 11, 2015 1:53:05 PM
	 * @return void
	 * @throw
	 */
	public void checkAllbgysjl() throws IOException{
		PrintWriter out = getResponse().getWriter();
	  	try {
	  		String returnValue ="";
	  		String taskId = getRequest().getParameter("taskId");
	  		String flag = getRequest().getParameter("flag");
	  		String ids = getRequest().getParameter("ids");
			//提交时校验
			if("0".equals(flag)){
				String sql = "select  t.id from flow_task_info t where  t.flow_state_id !='bgysjlff' and t.flow_state_id !='end' and t.flow_task_id= "+taskId;
				List list = autoFormService.getDatabySql(sql);
				if(null!=list&&list.size()>0){
					returnValue = "true";
				}else{
					returnValue = "false";
				}
			}
			//判断是否是最有一份原始记录或报告发放
			else if("1".equals(flag)){
				String sql1 = "select t.id  from gwm_item_sample t where (t.t_reportsftj is null or t.t_reportsftj=1) and t.t_taskid="+taskId+" and t.id not in ("+ids+") and t.t_sfdelete is null";
			    List list1 = autoFormService.getDatabySql(sql1);
				if(null==list1||list1.size()==0){
			    	//判断样品是否归还
					String sql2 = "select distinct t.id from gwm_sample t left join gwm_item_sample s on t.id = s.t_sampleid where t.t_sfguihuan=0 and s.t_sfdelete is null and t.t_taskid="+taskId;
					List list2 = autoFormService.getDatabySql(sql2);
					if(null!=list2&&list2.size()>0){
						returnValue = "true";
					}else{
						returnValue = "false";
					}
			    }else{
			    	returnValue = "false";
			    }
			}
			
			out.print("{\"ajaxResult\":\""+returnValue+"\"}");
			
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
		}
		
	}
	
	/**
	 * 
	 *方法描述:查询原始记录单模版
	 * 
	 * @author: wangxd
	 *@date: 2013-7-5下午08:33:54
	 */
	public void selectFileMode() {
		try {
			Map<String, String> filterMap = getPagerMap();
			String filename = getRequest().getParameter("filename");
			//String orgId = getRequest().getParameter("orgId");
			// 解决乱码问题
			if (filename != null && !"".equals(filename)) {
				filename = StringUtil.encodingUrl(filename);
			}
			filterMap.put("filename", filename);
			//filterMap.put("orgId", orgId);
			String[] viewArray = { "ID", "FILE_NAME", "ORG_NAME", "FILE_PATH","ROWINDEX","COLINDEX","MODETYPE"};
			String returnStr = "";
			PageResult result = codeReviewService.queryFilemodeList(filterMap);
			returnStr = getColumnJson(result, viewArray);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");// 定义输出的类型
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");// 定义输出的类型
			PrintWriter out = PubMethod.GetPrintWriter();
			System.out.println("--!" + returnStr + "--!");
			out.print(returnStr);
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void getReportAsPdf(){
		String type = getRequest().getParameter("type");
		String filepath = "";
		String pdfpath = "";
		if (type.equals("zc")){
			String mainid = this.getRequest().getParameter("mainid");
			String baogaosql = "select t.BAOGAO from GWM_YANFAJIANCE t  where t.id="+mainid+" and t.baogao is not null";
			List baogaoList= autoFormService.getDatabySql(baogaosql);
			filepath = baogaoList.get(0)==null?"":baogaoList.get(0).toString();
			pdfpath = filepath.replace(".docx", ".pdf").replace(".doc", ".pdf");
		}
		else{
			String itemid = getRequest().getParameter("itemid");
			String strSql = "select t.t_bgfilepath from gwm_item_sample t where id='"+itemid+"'";
			List lists = autoFormService.getDatabySql(strSql);
			filepath = lists.get(0)==null?"":lists.get(0).toString();
			pdfpath = filepath.replace(".docx", ".pdf").replace(".doc", ".pdf");
		}
		System.out.println(pdfpath);
		File pdffile = new File(pdfpath);
		if (pdffile.exists()){
			pdffile.delete();
		}
		
		WordTool wt = new WordTool(filepath);
		try{
			if (!filepath.equals("")){
				wt.SavePdf(pdfpath);
				InputStream ins=new FileInputStream(pdfpath);//构造一个读取文件的IO流对象
				BufferedInputStream bins=new BufferedInputStream(ins);//放到缓冲流里面
				OutputStream outs=getResponse().getOutputStream();//获取文件输出IO流
				BufferedOutputStream bouts=new BufferedOutputStream(outs);
				getResponse().setContentType("application/x-download");//设置response内容的类型
				getResponse().setHeader("Content-disposition","attachment;filename="+ URLEncoder.encode(pdfpath, "UTF-8"));//设置头部信息
				int bytesRead = 0;
				byte[] buffer = new byte[8192];
				//开始向网络传输文件流
				while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
					bouts.write(buffer, 0, bytesRead);
				}
				bouts.flush();//这里一定要调用flush()方法
				ins.close();
				bins.close();
				outs.close();
				bouts.close();
			}
		}
		catch(Exception exp){
			wt.Save();
			exp.printStackTrace();
		}
		
	}
	
	/**
	 * 下载所有的原始记录模版，合格证，打印单等等
	 * @throws Exception
	 */
	public void getTaskFileDownloadYsjlHgz() throws Exception{
		String pathname = getRequest().getParameter("path");
		String allpath = getRequest().getParameter("allpath");
		String bgpath = getRequest().getParameter("bgpath");
		String type = getRequest().getParameter("type");
		String pathUrl = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();
		String path1 = "";
		if(allpath != null && !allpath.equals("")){
			path1 = allpath;
		}else{
			if(bgpath != null && !bgpath.equals("")){
				path1 = bgpath;
			}else{
				path1 = pathUrl+"/taskfile/"+type+"/"+pathname;
			}
		}
		//String url = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();
		//String path = new String(getRequest().getParameter("filePath").getBytes("ISO-8859-1"));
		//path = url+"/"+StringUtil.encodingUrl(path);
		if(!"".equals(path1)){
			File file=new File(path1);//构造要下载的文件	
			if(file.exists()){
				InputStream ins=new FileInputStream(path1);//构造一个读取文件的IO流对象
				BufferedInputStream bins=new BufferedInputStream(ins);//放到缓冲流里面
				OutputStream outs=getResponse().getOutputStream();//获取文件输出IO流
				BufferedOutputStream bouts=new BufferedOutputStream(outs);
				getResponse().setContentType("application/x-download");//设置response内容的类型
				getResponse().setHeader("Content-disposition","attachment;filename="+ URLEncoder.encode(path1, "UTF-8"));//设置头部信息
				int bytesRead = 0;
				byte[] buffer = new byte[8192];
				//开始向网络传输文件流
				while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
					bouts.write(buffer, 0, bytesRead);
				}
				bouts.flush();//这里一定要调用flush()方法
				ins.close();
				bins.close();
				outs.close();
				bouts.close();
			}else{
				System.out.println("下载的文件不存在");
			}
		}else{
			System.out.println("下载文件时参数错误");
		}
	}
	
	public void getTaskFileDownloadYsjlHgzShowComment() throws Exception{
		PrintWriter out = getResponse().getWriter();
		String pathname = getRequest().getParameter("path");
		String allpath = getRequest().getParameter("allpath");
		String bgpath = getRequest().getParameter("bgpath");
		String type = getRequest().getParameter("type");
		String pathUrl = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();
		String path1 = "";
		if(allpath != null && !allpath.equals("")){
			path1 = allpath;
		}else{
			if(bgpath != null && !bgpath.equals("")){
				path1 = bgpath;
			}else{
				path1 = pathUrl+"/taskfile/"+type+"/"+pathname;
			}
		}
		String tomcatpath = ServletActionContext.getServletContext().getRealPath("/");
		File file1 = new File(path1);
		String path2 = tomcatpath+"excelfile\\"+file1.getName();
		File file2 = new File(path2);
		if (file2.exists())
		{
			file2.deleteOnExit();
		}
		copyFile(file1, new File(path2));
		out.print("{\"filename\":\""+file1.getName()+"\"}");
	}
	
	/**
	 * 下载原始记录并填充数据
	 * @throws Exception
	 */
	public void getYsjlAndFilldata() throws Exception{
		PrintWriter out = PubMethod.GetPrintWriter();
		ExcelTool et = null;
		try{
			String ids = getRequest().getParameter("ids");
			String junyansid = getRequest().getParameter("junyansid");
			String pathname = getRequest().getParameter("path");
			String type = getRequest().getParameter("type");
			String pathUrl = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();

			String path1 = "";
			path1 = pathUrl+"/taskfile/"+type+"/"+pathname;
			if(!"".equals(path1)){
				String fileFolder = pathUrl+"/taskfile/ysjltemp";
				File folder = new File(fileFolder);
				if(folder!=null&&!folder.exists()){ //新建文件夹
					folder.mkdirs();
				}
				String path2 = pathUrl+"/taskfile/ysjltemp/"+pathname;
				File targetfile = new File(path2);
				if (targetfile.exists()){
					targetfile.deleteOnExit();
				}
				copyFile(new File(path1), new File(path2));
				//获得label数据
				
				et = new ExcelTool(path2, true);
				Junyans junyans = (Junyans)epService.getDataById(Junyans.class, Long.parseLong(junyansid));
				if (junyans!=null){
					et.SetCellByName("l任务编号",junyans.getRenwubh());
					et.SetCellByName("l产品代号",junyans.getChanpindh());
					et.SetCellByName("l试验类型",junyans.getShiyanlx());
					et.SetCellByName("l负责人",junyans.getFuzher());
					et.SetCellByName("l试验地点",junyans.getShiyandd());
					et.SetCellByName("l涉密等级",junyans.getShemidj());
					et.SetCellByName("l试验开始时间",junyans.getShiyankssj());
					et.SetCellByName("l预计结束时间",junyans.getYujijssj());
					et.SetCellByName("l阶段类型",junyans.getJieduanlx());
					et.SetCellByName("l计划用弹量",junyans.getJihuaydl());
				}
				
				//项目信息
				String strSql = "select t1.id,t2.xiangmumc,t2.biaozunyq,t2.danwei,t2.shebeiyq from kl_junyans_xm t1" +
						" left join kl_ceshixm t2 on t1.xiangmuid=t2.id where t1.id in ("+ids+") order by t1.id";
				List listitems = codeReviewService.queryListBySql(strSql);

				//数据列表
				int[] dcposxiangmumc = et.GetCellPositionByName(1, "dc项目名称");
				if (dcposxiangmumc!=null){
					int[] dcposbiaozunyq = et.GetCellPositionByName(1, "dc标准要求");
					int[] dcposdanwei = et.GetCellPositionByName(1, "dc单位");
					int[] dcposshebeiyq = et.GetCellPositionByName(1, "dc设备要求");
					int meargeCount = et.GetCellMergeRows(1, dcposxiangmumc[0], dcposxiangmumc[1]);
					et.InsertRangesAndCopy(1, dcposxiangmumc[0], listitems.size(),meargeCount);
					for(int i=0;i<listitems.size();i++){
						Object[] objs = (Object[])listitems.get(i);
						if (objs[1]!=null){
							et.SetCells(dcposxiangmumc[0]+i*meargeCount, dcposxiangmumc[1], objs[1].toString());
						}
						if (objs[2]!=null && dcposbiaozunyq!=null ){
							et.SetCells(dcposbiaozunyq[0]+i*meargeCount, dcposbiaozunyq[1], objs[2].toString());
						}
						if (objs[3]!=null && dcposdanwei!=null ){
							et.SetCells(dcposdanwei[0]+i*meargeCount, dcposdanwei[1], objs[3].toString());
						}
						if (objs[4]!=null && dcposshebeiyq!=null ){
							et.SetCells(dcposshebeiyq[0]+i*meargeCount, dcposshebeiyq[1], objs[4].toString());
						}
					}
				}
				
				et.Save();
				out.print("{\"result\":\"success\"}");
			}else{
				System.out.println("下载文件时参数错误");
			}
		}
		catch(Exception exp){
			exp.printStackTrace();
			out.print("{\"result\":\""+exp.toString()+"\"}");
			if (et!=null){
				et.Close();
			}
		}
	}
	
	public String saveysjld() throws IOException
	{
		PrintWriter out = getResponse().getWriter();
		try {
			String ysjlpath = getRequest().getParameter("ysjlpath");  //原始记录单路径
			String filemodeId =  getRequest().getParameter("filemodeId");  //原始记录单模版Id
			String ids = getRequest().getParameter("ids");
			String flowtaskid = getRequest().getParameter("flowtaskid");
			String strSql = "";
			if (filemodeId==null||filemodeId.equals("")){
				strSql = "select FILEMODEID from KL_JUNYANS_XM where ID in ("+ids+")  ";
				List filemodeList = autoService.getDatabySql(strSql);
				if (filemodeList.size()>0){
					filemodeId = filemodeList.get(0).toString();
				}
			}
			strSql = "update KL_JUNYANS_XM t set t.FILEMODEID='"+filemodeId+"',t.YSJLPATH='"+ysjlpath+"' " +
			"where t.ID in ("+ids+") ";
			autoService.executeSql(strSql);
	
			//回写数据信息部分
			ExcelTool et = new ExcelTool(ysjlpath);
			strSql = "select form_en_name from auto_forms_new t where t.id in (select baseinfoid from file_mode where id='"+filemodeId+"' )";
			List baseTableList = autoService.getDatabySql(strSql);
			if (baseTableList.size()>0){
				int hasvalue = 0;
				String tablename = baseTableList.get(0).toString();
				strSql = "delete from "+tablename+" where FLOWTASKID='"+flowtaskid+"' and FILEMODEID='"+filemodeId+"'";
				autoService.executeSql(strSql);
				strSql = "select FIELD_NAME from auto_forms_field t where " +
				"forms_id in (select baseinfoid from file_mode where id='"+filemodeId+"' ) " +
				"and field_name not in ('ID','FLOWTASKID','FILEMODEID')";
				List baseFieldList = autoService.getDatabySql(strSql);
				String filednames = "";
				String filedvalues = "";
				for(int i=0;i<baseFieldList.size();i++){
					String fieldname = baseFieldList.get(i).toString();
					int[] dcresultdata = et.GetCellPositionByName(1, "fl_"+fieldname);
					if (dcresultdata!=null){
						String fieldvalue = et.GetCellText(dcresultdata[0], dcresultdata[1]);
						filednames+=","+fieldname;
						filedvalues+=",'"+fieldvalue+"'";
						hasvalue =1;
					}
				}
				if (hasvalue==1){
					strSql = "insert into "+tablename+" (ID,FLOWTASKID,FILEMODEID"+filednames+") values (SEQ_"+tablename+".NEXTVAL,'"+flowtaskid+"','"+filemodeId+"'"+filedvalues+")";
					autoService.executeSql(strSql);
				}
			}
			
			strSql = "select form_en_name from auto_forms_new t where t.id in (select datainfoid from file_mode where id='"+filemodeId+"' )";
			List dataTableList = autoService.getDatabySql(strSql);
			if (dataTableList.size()>0){
				String tablename = dataTableList.get(0).toString();
				strSql = "delete from "+tablename+" where FLOWTASKID='"+flowtaskid+"' and FILEMODEID='"+filemodeId+"'";
				autoService.executeSql(strSql);
				strSql = "select FIELD_NAME from auto_forms_field t where " +
				"forms_id in (select datainfoid from file_mode where id='"+filemodeId+"' ) " +
				"and field_name not in ('ID','FLOWTASKID','FILEMODEID')";
				List dataFieldList = autoService.getDatabySql(strSql);

				int[] ldatastart = et.GetCellPositionByName(1, "ldatastart");
				int rowStartIndex = -1;
				if (ldatastart!=null){
					rowStartIndex = ldatastart[0];
				}
				int[] ldataend = et.GetCellPositionByName(1, "ldataend");
				int rowEndIndex = -1;
				if (ldataend!=null){
					rowEndIndex = ldataend[0];
				}
				
				String filednames = "";
				List<int[]> dataaddressList = new ArrayList<int[]>();
				for(int i=0;i<dataFieldList.size();i++){
					String fieldname = dataFieldList.get(i).toString();
					int[] dcresultdata = et.GetCellPositionByName(1, "fdc_"+fieldname);
					if (dcresultdata!=null){
						filednames+=","+fieldname;
						dataaddressList.add(dcresultdata);
					}
				}
				
				if (rowStartIndex!=-1&&rowEndIndex!=-1&&rowEndIndex>rowStartIndex){
					for(int i=rowStartIndex;i<rowEndIndex;i++){
						int hasvalue =0;
						String filedvalues = "";
						for(int j=0;j<dataaddressList.size();j++){
							String fieldvalue = et.GetCellText(i, dataaddressList.get(j)[1]);
							filedvalues+=",'"+fieldvalue+"'";
							if (j==0&&(!fieldvalue.equals(""))){
								hasvalue =1;
							}
						}
						if (hasvalue==1){
							strSql = "insert into "+tablename+" (ID,FLOWTASKID,FILEMODEID"+filednames+") values (SEQ_"+tablename+".NEXTVAL,'"+flowtaskid+"','"+filemodeId+"'"+filedvalues+")";
							autoService.executeSql(strSql);
						}
					}
				}
			}
			et.Save();
			out.print("{\"ajaxResult\":\"success\"}");
			
			
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
		}
		out.flush();
		out.close();
    	return null;
	}
	
	//处理列表
	public void dealYsjlDc(ExcelTool et,int[] dcresultdata,String ids){
		//项目信息
		String strSql = "select t1.id from kl_junyans_xm t1" +
				" left join kl_ceshixm t2 on t1.xiangmuid=t2.id where t1.id in ("+ids+") order by t1.id";
		List listitems = codeReviewService.queryListBySql(strSql);
		int meargeCount = et.GetCellMergeRows(1,dcresultdata[0],dcresultdata[1]);
		for(int i=0;i<listitems.size();i++){
			String id = listitems.get(i).toString();
			String result = et.GetCellText(dcresultdata[0]+i*meargeCount, dcresultdata[1]);
			if (result!=null && !result.equals("")){
				strSql = "update KL_JUNYANS_XM t set t.JIEGUO='"+result+"' " +
						"where t.ID='"+id+"' ";
				autoService.executeSql(strSql);
			}
		}
	}
	
	
	//处理交叉表
	public void dealYsjlDx(String taskId,ExcelTool et,int[] dxsamplecode,int[] dxaddress,String ids){
		//项目信息
		String strSql = "select T.ID,T.T_SAMPLENO,T.t_jiancecanshu,s.t_samplename,s.t_chexingbianma,s.T_JIESHOUTIME," +
		"s.t_pici,s.t_manufacturer FROM GWM_ITEM_SAMPLE T  " +
		"LEFT JOIN GWM_SAMPLE S  ON T.T_SAMPLEID=S.ID  " +
		"LEFT JOIN TDM_ANNEX T1 ON S.T_ANNEX=T1.ID " +
		"LEFT JOIN GWM_ITEM_FLOW I ON T.T_ITEMID = I.ID " +
		"LEFT JOIN TDM_ANNEX T2 ON I.T_ANNEX=T2.ID " +
		"LEFT JOIN SYS_ORGANIZATION O on T.T_DEPTID = O.ORG_ID  " +
		"WHERE 1=1 and T.T_TASKID ='"+taskId+"'  and T.T_REPORTSFTJ  is null and t.id in ("+ids+") order by T.T_SAMPLENO,T.t_jiancecanshu";
		List listitems = codeReviewService.queryListBySql(strSql);
		
		//样品列表
		strSql = "select distinct T.T_SAMPLENO FROM GWM_ITEM_SAMPLE T  " +
		"LEFT JOIN GWM_SAMPLE S  ON T.T_SAMPLEID=S.ID  " +
		"LEFT JOIN TDM_ANNEX T1 ON S.T_ANNEX=T1.ID " +
		"LEFT JOIN GWM_ITEM_FLOW I ON T.T_ITEMID = I.ID " +
		"LEFT JOIN TDM_ANNEX T2 ON I.T_ANNEX=T2.ID " +
		"LEFT JOIN SYS_ORGANIZATION O on T.T_DEPTID = O.ORG_ID  " +
		"WHERE  T.T_TASKID ='"+taskId+"' and T.ID in ("+ids+")   and T.T_REPORTSFTJ  is null order by T.T_SAMPLENO";
		List listsamples = codeReviewService.queryListBySql(strSql);
		
		for(int i=0;i<listsamples.size();i++){
			String sampleno = listsamples.get(i).toString();
			for(int j=0;j<listitems.size();j++){
				Object[] objitems = (Object[])listitems.get(j);
				String itemname = objitems[2].toString();
				String result = et.GetCellText(dxsamplecode[0]+i, dxaddress[1]+j);
				if (result!=null && !result.equals("")){
					strSql = "update GWM_ITEM_SAMPLE t set t.t_result='"+result+"' " +
							"where t.T_SAMPLENO='"+sampleno+"' and t.t_jiancecanshu='"+itemname+"'";
					autoService.executeSql(strSql);
				}
			}
		}
	}
	
	
	//处理固定
	public void dealYsjlDg(String taskId,ExcelTool et,String ids){
		//项目信息
		String strSql = "select distinct T_GMW_ITEM_ID from ( select  T.T_GMW_ITEM_ID,T.T_JIANCEBIAOZHUN  FROM GWM_ITEM_SAMPLE T  " +
		"LEFT JOIN GWM_SAMPLE S  ON T.T_SAMPLEID=S.ID  LEFT JOIN TDM_ANNEX T1 ON S.T_ANNEX=T1.ID " +
		"LEFT JOIN GWM_ITEM_FLOW I ON T.T_ITEMID = I.ID LEFT JOIN TDM_ANNEX T2 ON I.T_ANNEX=T2.ID " +
		"LEFT JOIN SYS_ORGANIZATION O on T.T_DEPTID = O.ORG_ID  WHERE  T.T_TASKID ='"+taskId+"'  and T.ID in ("+ids+")  and T.T_REPORTSFTJ  is null)";
		List listitems = codeReviewService.queryListBySql(strSql);
		for(int j=0;j<listitems.size();j++){
			String itemid = listitems.get(j).toString();
			strSql = "select distinct t.t_itemname,t.t_jiancedanwei,t.t_jiancecanshu from gwm_item t where t.id='"+itemid+"' ";
			List listiteminfos = codeReviewService.queryListBySql(strSql);
			Object[] iteminfo = (Object[])listiteminfos.get(0);
			String itemname = iteminfo[0]==null?"":iteminfo[0].toString();
			String jiancedidian = iteminfo[1]==null?"":iteminfo[1].toString();
			String jiancecanshu = iteminfo[2]==null?"":iteminfo[2].toString();
			String strwhere = " where t.t_itemname='"+itemname+"' and t.t_jiancedanwei='"+jiancedidian+"' ";
			if (!jiancecanshu.equals("")){
				strwhere += "  and t.t_jiancecanshu='"+jiancecanshu+"' ";
			}
			strSql = "select distinct t.id from gwm_item t  "+strwhere;
			List listitems1 = codeReviewService.queryListBySql(strSql);
			for(int i=0;i<listitems1.size();i++){
				String itemid1 = listitems1.get(i).toString();
				int[] dgitemid1 = et.GetCellPositionByName(1, "dguding"+itemid1);
				if (dgitemid1!=null){
					String result = et.GetCellText(dgitemid1[0], dgitemid1[1]);
					if (result!=null && !result.equals("")){
						strSql = "update GWM_ITEM_SAMPLE t set t.t_result='"+result+"' " +
								"where t.T_TASKID='"+taskId+"' and t.T_GMW_ITEM_ID='"+itemid1+"' ";
						autoService.executeSql(strSql);
					}
				}
			}
		}
	}
	
	/**
	 * 
	 *方法描述:进入填写原始记录单页面
	 *@author: wangxd
	 *@date: 2013-11-15下午07:20:21
	 *@throws Exception
	 */
	public void getYsjlfilename() throws Exception{
		PrintWriter out = PubMethod.GetPrintWriter(); 
		String operateType = getRequest().getParameter("operateType"); //0：编辑原始记录  1：查看原始记录单
		String ids = this.getRequest().getParameter("ids");
		JSONObject json1 = new  JSONObject();

		String path = "";
		
		String sql = "select t.ysjlpath from kl_junyans_xm t where t.id in ("+ids+")";
		//查询原始记录单
		List ysjlList= autoFormService.getDatabySql(sql);
		
		if(null!=ysjlList&&ysjlList.size()>0){
			if(null!=ysjlList.get(0)&&ysjlList.size()>0&&null!=ysjlList.get(0)){//11
				path = ysjlList.get(0)!=null?ysjlList.get(0).toString():"";
			}
		}
		json1.put("ids", ids);
	    json1.put("path", path);
	    System.out.println(json1.toString());
	    out.print(json1.toString());
	}
	
	/**
	 * 
	 *方法描述:查询报告模版
	 *@author: wangxd
	 *@date: 2014-8-4下午04:22:28
	 */
	public void selectReportFileMode() {
		try {
			Map<String, String> filterMap = getPagerMap();
			String filename = getRequest().getParameter("filename");
			String orgId = getRequest().getParameter("orgId");
			// 解决乱码问题
			if (filename != null && !"".equals(filename)) {
				filename = StringUtil.encodingUrl(filename);
			}
			filterMap.put("filename", filename);
			filterMap.put("orgId", orgId);
			String[] viewArray = { "ID", "REPORT_NAME", "REPORT_PATH","ORG_NAME"};
			String returnStr = "";
			PageResult result = codeReviewService.queryReportFilemodeList(filterMap);
			returnStr = getColumnJson(result, viewArray);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");// 定义输出的类型
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");// 定义输出的类型
			PrintWriter out = PubMethod.GetPrintWriter();
			System.out.println("--!" + returnStr + "--!");
			out.print(returnStr);
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 填写报告内容
	 * @throws Exception
	 */
	public void getReportAndFilldata() throws Exception{
		PrintWriter out = PubMethod.GetPrintWriter();
		WordTool wt = null;
		try{
			String pathname = getRequest().getParameter("path");
			String allpath = getRequest().getParameter("allpath");
			String type = getRequest().getParameter("type");
			String filemodeid = getRequest().getParameter("filemodeid");
			String junyansid = getRequest().getParameter("junyansid");
			String pathUrl = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();

			String path1 = "";
			path1 = pathUrl+"/taskfile/"+type+"/"+pathname;

			if(!"".equals(path1)){
				String fileFolder = pathUrl+"/taskfile/reporttemp";
				File folder = new File(fileFolder);
				if(folder!=null&&!folder.exists()){ //新建文件夹
					folder.mkdirs();
				}
				String path2 = pathUrl+"/taskfile/reporttemp/"+pathname;
				File targetfile = new File(path2);
				if (targetfile.exists()){
					targetfile.deleteOnExit();
				}
				copyFile(new File(path1), new File(path2));
				//获得label数据
				wt = new WordTool(path2);
				Junyans junyans = (Junyans)epService.getDataById(Junyans.class, Long.parseLong(junyansid));
				if (junyans!=null){
					wt.SetBookMarkValue("l任务编号",junyans.getRenwubh());
					wt.SetBookMarkValue("l产品代号",junyans.getChanpindh());
					wt.SetBookMarkValue("l试验类型",junyans.getShiyanlx());
					wt.SetBookMarkValue("l负责人",junyans.getFuzher());
					wt.SetBookMarkValue("l试验地点",junyans.getShiyandd());
					wt.SetBookMarkValue("l涉密等级",junyans.getShemidj());
					wt.SetBookMarkValue("l试验开始时间",junyans.getShiyankssj());
					wt.SetBookMarkValue("l预计结束时间",junyans.getYujijssj());
					wt.SetBookMarkValue("l阶段类型",junyans.getJieduanlx());
					wt.SetBookMarkValue("l计划用弹量",junyans.getJihuaydl());
				}
				
				//项目信息
				String strSql = "select t1.id,t2.xiangmumc,t2.biaozunyq,t2.danwei,t2.shebeiyq,t1.jieguo from kl_junyans_xm t1" +
						" left join kl_ceshixm t2 on t1.xiangmuid=t2.id where t1.junyansid="+junyansid+" order by t1.id";
				List listitems = codeReviewService.queryListBySql(strSql);

		        //处理列表样品结果及数据部分
		        int[] dcposxiangmumc = wt.GetTableIndexByMark("dc项目名称");
		        if (dcposxiangmumc!=null){
		        	int[] dcposbiaozhunyq = wt.GetTableIndexByMark("dc标准要求");
					int[] dcposdanwei = wt.GetTableIndexByMark("dc单位");
					int[] dcposshebeiyq = wt.GetTableIndexByMark("dc设备要求");
					int[] dcposjieguo = wt.GetTableIndexByMark("dc结果");

					wt.InsertRows(dcposxiangmumc[0], dcposxiangmumc[1], listitems.size()-1);
					for(int i=0;i<listitems.size();i++){
						Object[] objs = (Object[])listitems.get(i);
						if (objs[1]!=null){
							wt.SetTableText(dcposxiangmumc[0], dcposxiangmumc[1]+i, dcposxiangmumc[2], objs[1].toString());
						}
						if (objs[2]!=null && dcposbiaozhunyq!=null){
							wt.SetTableText(dcposbiaozhunyq[0], dcposbiaozhunyq[1]+i, dcposbiaozhunyq[2], objs[2].toString());
						}
						if (objs[3]!=null && dcposdanwei!=null){
							wt.SetTableText(dcposdanwei[0], dcposdanwei[1]+i, dcposdanwei[2], objs[3].toString());
						}
						if (objs[4]!=null && dcposshebeiyq!=null){
							wt.SetTableText(dcposshebeiyq[0], dcposshebeiyq[1]+i, dcposshebeiyq[2], objs[4].toString());
						}
						if (objs[5]!=null && dcposjieguo!=null){
							wt.SetTableText(dcposjieguo[0], dcposjieguo[1]+i, dcposjieguo[2], objs[5].toString());
						}
					}
		        }
		        
				wt.Save();
				out.print("{\"result\":\"success\"}");
			}else{
				System.out.println("下载文件时参数错误");
			}
		}
		catch(Exception exp){
			out.print("{\"result\":\"error\"}");
			if (wt!=null){
				wt.Save();
			}
			exp.printStackTrace();
		}
	}
	
	
	/**
	 * 
	 *方法描述:编辑报告
	 *@author: wangxd
	 *@date: 2014-4-22下午02:55:47
	 */
	public void getReportfilename()
	{
		PrintWriter out = PubMethod.GetPrintWriter(); 
		String operateType = getRequest().getParameter("operateType"); //0：编辑原始记录  1：查看原始记录单
		String junyansid = this.getRequest().getParameter("junyansid");
		JSONObject json = new  JSONObject();

		String path = "";
		
		String sql = "select t.reportpath from kl_junyans t where t.id="+junyansid;
		//查询原始记录单
		List ysjlList= autoFormService.getDatabySql(sql);
		
		if(null!=ysjlList&&ysjlList.size()>0){
			if(null!=ysjlList.get(0)&&ysjlList.size()>0&&null!=ysjlList.get(0)){//11
				path = ysjlList.get(0)!=null?ysjlList.get(0).toString():"";
			}
		}
		json.put("path", path);
	    //System.out.println(json.toString());
	    out.print(json.toString());
	}
	/**
	 * 
	 * 描述：查询标签对应的基本信息
	 * @author wangxd
	 * @date Aug 5, 2015 5:25:55 PM
	 * @return JSONArray
	 * @throw
	 */
	private JSONArray queryFlowGonggMsg(String filemodeId,String mainId){
		JSONArray jsonarrayBd = new JSONArray();
		 List itemList1 = codeReviewService.queryFlowItemByFileModeId(Long.parseLong(filemodeId), "1");    //流程
		    if(null!=itemList1&&itemList1.size()>0){
		    	for(int i =0; i<itemList1.size();i++){
					JSONObject json = new JSONObject();
					Object[] objs = (Object[])itemList1.get(i);
					if(objs[0] != null){
						String labelValue = "";
						String  tablename = objs[1]!=null?objs[1].toString():"";
						String filedEnName = objs[2]!=null?objs[2].toString():"";
						if(!"".equals(tablename)&&!"".equals(filedEnName)&&objs[0]!=null){
							//根据配置标签的关系 去查询数据库里对应的值
							String sql1 = "select "+filedEnName +" from "+tablename +" t where t.id="+mainId;
							List biaoqianList= autoFormService.getDatabySql(sql1);
							if(null!=biaoqianList&&biaoqianList.size()>0&&null!=biaoqianList.get(0)){
								labelValue = biaoqianList.get(0).toString();
								json.put("label", objs[0].toString());
								json.put("labelValue",labelValue );
								jsonarrayBd.add(json);
							}else{
								json.put("label", objs[0].toString());
								json.put("labelValue","" );
								jsonarrayBd.add(json);
							}
						}
					}
				}
		    }
		    return jsonarrayBd;
	}
	/**
	 * 
	 *方法描述:上传报告
	 * 
	 * @author: wangxd
	 *@date: 2013-8-10下午06:12:44
	 *@return
	 *@throws IOException
	 */
	public void saveUploadFileId() throws IOException {
		setContentType();
		String returnValue ="";
		PrintWriter out = PubMethod.GetPrintWriter(); 
		String itemflowid = getRequest().getParameter("itemflowid");
		String flag  = getRequest().getParameter("flag");    //0:选择项目上传附件  1:原始记录上传附件
		String flowtaskId = getRequest().getParameter("flowtaskId");  
		String contentType = this.getRequest().getContentType();
//		String maxSize = getRequest().getSession().getServletContext().getInitParameter("maxSize");
		try {
			if (contentType == null|| !contentType.startsWith("multipart/form-data")) // 没有文件提交
			{
			}
			else {
				List files = getUploadfile();
				StringBuilder sb = new StringBuilder();
				for (int i = 0; i < files.size(); i++) {
					String fileName = (String) getUploadfileFileName().get(i);
					String fileType = fileName.substring(
							(fileName.lastIndexOf(".")) + 1, fileName.length());
					File ff = new File(files.get(i).toString());
					if (ff.length() > 0 ) // 大于30M
				
					{
						ActionContext ac = ActionContext.getContext();
				        ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
				        String url = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();
				        
				        SimpleDateFormat simpleDateFormat =  new SimpleDateFormat("yyyyMM");
					    String date = simpleDateFormat.format(new Date());
					    if("0".equals(flag)){
					    	url = url +"/annex/"+date;
					    }
					    else if("1".equals(flag)){
					    	url = url +"/taskfile/"+date+"/"+flowtaskId;
					    }
					    
						File file = new File(url);
						if ( ! (file.exists())  &&   ! (file.isDirectory()))  {
			                 boolean  creadok  =  file.mkdirs();
			                 if (creadok)  {
			                    System.out.println( " ok:创建文件夹成功！ " );
			                } else  {
			                    System.out.println( " err:创建文件夹失败！ " );                    
			                } 
			            } 
						SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMddHHmmssSSS");
						String address = "/"+sdf1.format(System.currentTimeMillis())+"."+ fileType;
						FileOutputStream fos = new FileOutputStream(url+address); 
						FileInputStream fis = new FileInputStream(files.get(i).toString()); 
						byte[] buffer = new byte[1024]; 
						int len = 0; 
						while ((len = fis.read(buffer)) > 0) 
						{ 
							fos.write(buffer, 0, len);
						} 
						fos.close();
						fis.close();
					    if("0".equals(flag)){
					    	//将附件保存到Tdm_annex中
							TdmAnnex annex = new TdmAnnex();
							annex.setFileName(getUploadfileFileName().get(i).toString());
							annex.setFilePath("/annex/"+date+"/"+address);
							annex.setAnnexType(1l);
							annex.setCreateTime(new Date());
							annex.setCreateUserid(Long.parseLong(this.getUserId()));
							annex.setCreateUsername(this.getUserName());
							String annexId = autoService.saveObject(annex);
							
							//修改流程中检测项目的附件
							String sql = " update gwm_item_flow t set t.t_annex='"+annexId+"' where t.id in ("+itemflowid+")";
							autoFormService.executeSql(sql);
					    }
					    else if("1".equals(flag)){
					    	//修改流程中 原始记录附件
					    	address = "/taskfile/"+date+"/"+flowtaskId+"/"+address;
							String sql = " update gwm_item_sample t set t.t_ysjlannex='"+address+"',t.t_ysjlannexname ='"+getUploadfileFileName().get(i).toString()+"' where t.id  in ( "+itemflowid+")";
							autoFormService.executeSql(sql);
					    }
						returnValue = "success";
						
					} else if (ff.length() == 0) {
						returnValue ="uploadKong";
					} 
				}
			}
			out.print("{\"ajaxResult\":\""+returnValue+"\"}");
		} catch (Exception e) {
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	
	/**
	 * 
	 * 描述：下载附件
	 * @author wangxd
	 * @date Jul 20, 2015 3:19:17 PM
	 * @return void
	 * @throws UnsupportedEncodingException 
	 * @throw
	 */
	public void downloafAnnex() throws UnsupportedEncodingException{
			String fileAddress = "";
			String fileName = "";
			String id = getRequest().getParameter("id");
			String flag = getRequest().getParameter("flag");
			String url = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();
			if (!"".equals(id) && !"".equals(flag) && "0".equals(flag)) {     //常规检测流程中 下载样品附件和检测项目的附件
				 TdmAnnex tdmannex = codeReviewService.queryTdmAnnexById(Long.parseLong(id));
				 fileName = tdmannex.getFileName();
				 fileAddress = url+"/"+tdmannex.getFilePath();
			}
			else if (!"".equals(id) && !"".equals(flag) && "1".equals(flag)) {     //常规检测流程中 原始记录附件
				 String sql = "select t.t_ysjlannex,t.t_ysjlannexname  from gwm_item_sample t where t.t_ysjlannex is not null and t.t_ysjlannexname is not null and t.id ="+id;
				 List list = autoFormService.getDatabySql(sql);
				 if(null!=list&&list.size()>0&&null!=list.get(0)){
					 Object[] obj = (Object[])list.get(0);
					 fileName = obj[1].toString();
					 fileAddress = url+"/"+obj[0].toString();
				 }
				 
			}
			else if(!"".equals(flag)&&"2".equals(flag)){ 
				fileName = getRequest().getParameter("fileName");
				fileAddress = ServletActionContext.getServletContext().getRealPath("/")+fileName;
			}
			File downloadFile = new File(fileAddress);
			if (downloadFile.exists()) {
				getResponse().setHeader("Server", "www.tjtt.com");
				getResponse().setHeader("Content-Type", "application/octet-stream");
				getResponse().setHeader("Content-Length",String.valueOf(downloadFile.length()));
			
				getResponse().setHeader(
						"Content-Disposition",
						"attachment; filename=\""+ java.net.URLEncoder.encode(fileName, "UTF-8").replace("+", "%20") + "\"");
				try {
					OutputStream downloadStream = getResponse().getOutputStream();
					FileInputStream fin = new FileInputStream(downloadFile);
					byte[] b = new byte[1024];
					int length = fin.read(b);
					while (length > 0) {
						downloadStream.write(b, 0, length);
						length = fin.read(b);
					}
					downloadStream.flush();
					fin.close();
					addMessage("下载成功！");
				} catch (IOException e) {
					e.printStackTrace();
				}
			} else {
				addMessage("下载失败！");
				getResponse().setHeader("Content-Type", "text/html; charset=UTF-8");
				try {
					addMessage("下载失败！");
					getResponse().getWriter().write("<html>");
					getResponse().getWriter().write("<head>");
					getResponse().getWriter().write("</head>");
					getResponse().getWriter().write("<body>");
					getResponse().getWriter().write("文件没有找到<br>");
					getResponse()
							.getWriter()
							.write(
									"<a href='#' onclick='javascript:history.back(-1)'>返回</a>");
					getResponse().getWriter().write("</body>");
					getResponse().getWriter().write("</html>");
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			addMessage("下载成功！");
    }
	
	/**
	 * 获取系统统一序列ID
	 * @return
	 */
	public String getID(){
		try {
			WebApplicationContext factory = WebApplicationContextUtils.getRequiredWebApplicationContext(getRequest().getSession().getServletContext());  
			ConfigService configService =  (ConfigService)factory.getBean("configService");
			return configService.getSeqTdm();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	/*
	 * 研发检测流程----生成委托单识别号
	 * wxj
	 */
	public void getWeituodanChuli(String mainid,String flowtaskid){
	  		String sqlZ = "select t.id from GWM_YANFAJIANCE t where  t.weituodanshibieno is not null and t.id="+mainid;
			List listZ = autoFormService.getDatabySql(sqlZ);
			if(null !=listZ && listZ.size()>0){
			}else{
		  		Calendar a=Calendar.getInstance();
				String year = String.valueOf(a.get(Calendar.YEAR));
				year = year.substring(year.length()-2, year.length());
				
				String sql = "select  j.t_gongsidaima  from GWM_YANFAJIANCE t left join gwm_jiancedanwei  j on t.jiancedanwei = j.id  where t.id="+mainid;
				List list = autoFormService.getDatabySql(sql);
				String gongsidaima = "";
				if(null!=list&&list.size()>0&&null!=list.get(0)){
					
					gongsidaima = list.get(0).toString();
				}
		  		String weituodanshibieno = "WT"+year+"-"+gongsidaima+"-";
		  		WebApplicationContext factory = WebApplicationContextUtils.getRequiredWebApplicationContext(getRequest().getSession().getServletContext());  
				WeituodanService weituodanService =  (WeituodanService)factory.getBean("weituodanService");
				List list1 = weituodanService.queryWeituodanShibieno(year);
				if(null != list1 && list1.size()>0){
					if(null != list1.get(0) && !"".equals(list1.get(0))){
						int number = Integer.parseInt(list1.get(0).toString())+1;
						weituodanshibieno = weituodanshibieno + new DecimalFormat("0000").format(number);
					}else{
						weituodanshibieno = weituodanshibieno + "01";
					}
					String insertSql = "insert into WEITUODAN_SHIBIEHAO (ID,SHIBIEHAO,TASKID) values (SEQ_WORKFLOWDETAIL_ID.nextVal,'"+weituodanshibieno+"','"+flowtaskid+"')";
					autoService.executeSql(insertSql);
					String sqlupdate = "update GWM_YANFAJIANCE t set t.weituodanshibieno = '"+weituodanshibieno+"' where t.weituodanshibieno is null and t.id="+mainid;;
					autoService.executeSql(sqlupdate);
				}
//		  		String sql1 = "select max(substr(t.weituodanshibieno,length(t.weituodanshibieno)-3,4)) from GWM_YANFAJIANCE t where  t.weituodanshibieno like '%"+year+"-%'";
//				List list1 = autoFormService.getDatabySql(sql1);
//				if(null != list1 && list1.size()>0){
//					if(null != list1.get(0) && !"".equals(list1.get(0))){
//						int number = Integer.parseInt(list1.get(0).toString())+1;
//						weituodanshibieno = weituodanshibieno + new DecimalFormat("0000").format(number);
//					}else{
//						weituodanshibieno = weituodanshibieno + "0001";
//					}
//					String sqlupdate = "update GWM_YANFAJIANCE t set t.weituodanshibieno = '"+weituodanshibieno+"' where t.weituodanshibieno is null and t.id="+mainid;;
//					autoService.executeSql(sqlupdate);
//				}
			}
	}
	
	/*
	 * 获取研发检测流程原始记录excel名称
	 * wxj
	 */
	public void loadYFJCYSJLFilePath(){
		PrintWriter out = PubMethod.GetPrintWriter(); 
		JSONObject json1 = new  JSONObject();
		JSONArray jsonarray = new JSONArray();
		JSONArray jsonarrayBd = new JSONArray();
		String fileModeName="";
		String fileModeId = this.getRequest().getParameter("fileModeID");
		String mainid = getRequest().getParameter("mainid");
		String flag = "0";
		//查询原始记录路径
		String ysjlsql = "select t.YUANSHIJILUURL from GWM_YANFAJIANCE t where t.id="+mainid+" and t.YUANSHIJILUURL is not null";
		List ysjlList= autoFormService.getDatabySql(ysjlsql);
		if(null != ysjlList && ysjlList.size()>0){//若存在
			String filePath = ysjlList.get(0).toString();
			String[] filePaths = filePath.split("\\/");  
			String filename = "";
			if(null != filePaths && !"".equals(filePaths)){
				fileModeName = filePaths[filePaths.length-1];
			}
			flag = "1";
		}else{//若不存在
//			String sql = "select FILE_NAME,FILE_PATH from FILE_MODE t where id='"+fileModeId+"'";
//			//查询baogao 
//			List fileModeList= autoFormService.getDatabySql(sql);
//		    if(null!=fileModeList&&fileModeList.size()>0){
//		    	Object[]obj = (Object[])fileModeList.get(0);
//				fileModeName = obj[1]!=null?obj[1].toString():"";            //文件名称
//		    	//拷贝原始记录单
//		    	String tomcatpath=ServletActionContext.getServletContext().getRealPath("/");
//		    }
		}
	    //生成原始记录识别号
	    
//	    Calendar a=Calendar.getInstance();
//		String year = String.valueOf(a.get(Calendar.YEAR));
//		year = year.substring(year.length()-2, year.length());
//		
//		String sql2 = "select  j.t_gongsidaima  from GWM_YANFAJIANCE t left join gwm_jiancedanwei  j on t.jiancedanwei = j.id  where t.id="+mainid;
//		List list = autoFormService.getDatabySql(sql2);
//		String gongsidaima = "";
//		if(null!=list&&list.size()>0&&null!=list.get(0)){
//			
//			gongsidaima = list.get(0).toString();
//		}
//  		String yuanshijilushibieno = "YS"+year+"-"+gongsidaima+"-";
//  		
//  		String sql1 = "select max(substr(t.YUANSHIJILUSHIBIENO,length(t.YUANSHIJILUSHIBIENO)-3,4)) from GWM_YANFAJIANCE t where  t.YUANSHIJILUSHIBIENO like '%"+year+"-%'";
//		List list1 = autoFormService.getDatabySql(sql1);
//		if(null != list1 && list1.size()>0){
//			if(null != list1.get(0) && !"".equals(list1.get(0))){
//				int number = Integer.parseInt(list1.get(0).toString())+1;
//				yuanshijilushibieno = yuanshijilushibieno + new DecimalFormat("0000").format(number);
//			}else{
//				yuanshijilushibieno = yuanshijilushibieno + "0001";
//			}
//			String sqlupdate = "update GWM_YANFAJIANCE t set t.YUANSHIJILUSHIBIENO = '"+yuanshijilushibieno+"' where t.YUANSHIJILUSHIBIENO is null and t.id="+mainid;
//			autoService.executeSql(sqlupdate);
//		}
//		String sqlshibieno = "select t.YUANSHIJILUSHIBIENO from GWM_YANFAJIANCE t where t.id="+mainid;
//		List sqlshibienoList = autoFormService.getDatabySql(sqlshibieno);
//		if(null != sqlshibienoList && sqlshibienoList.size()>0){
//			json1.put("yuanshijilushibieno", sqlshibienoList.get(0));
//		}
	    json1.put("fileModeName", fileModeName);
	    json1.put("flag", flag);
	    out.print(json1.toString());
	}
	/*
	 * 保存研发检测流程原始记录
	 * wxj
	 */
	public void saveYanfajianceYSJL() throws IOException{
		PrintWriter out=getResponse().getWriter();
		try{
			String mainid = getRequest().getParameter("mainid");
			String yuanshijiluurl = getRequest().getParameter("yuanshijiluurl");
			String sqlupdate = "update GWM_YANFAJIANCE t set t.YUANSHIJILUURL = '"+yuanshijiluurl+"' where t.id="+mainid;
			autoService.executeSql(sqlupdate);
		 out.print("{\"ajaxResult\":\"success\"}");
	     out.flush();
		 out.close();
		} catch (Exception e) {
			e.printStackTrace();
			 out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	/*
	 * 加载已保存的研发检测流程原始记录
	 * wxj
	 */
	public void getYFJCYSJLDownload() throws Exception{
		String pathname = getRequest().getParameter("path");
		String allpath = getRequest().getParameter("allpath");
		String type = getRequest().getParameter("type");
		String taskid = getRequest().getParameter("taskid");
		String pathUrl = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();
		String path1 = "";
		if(allpath != null && !allpath.equals("")){
			path1 = allpath;
		}else{
			path1 = pathUrl+"/yanfajianceysjl/"+taskid+"/"+pathname;
		}
		if(!"".equals(path1)){
			File file=new File(path1);//构造要下载的文件	
			if(file.exists()){
				InputStream ins=new FileInputStream(path1);//构造一个读取文件的IO流对象
				BufferedInputStream bins=new BufferedInputStream(ins);//放到缓冲流里面
				OutputStream outs=getResponse().getOutputStream();//获取文件输出IO流
				BufferedOutputStream bouts=new BufferedOutputStream(outs);
				getResponse().setContentType("application/x-download");//设置response内容的类型
				getResponse().setHeader("Content-disposition","attachment;filename="+ URLEncoder.encode(path1, "UTF-8"));//设置头部信息
				int bytesRead = 0;
				byte[] buffer = new byte[8192];
				//开始向网络传输文件流
				while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
					bouts.write(buffer, 0, bytesRead);
				}
				bouts.flush();//这里一定要调用flush()方法
				ins.close();
				bins.close();
				outs.close();
				bouts.close();
			}else{
				System.out.println("下载的文件不存在");
			}
		}else{
			System.out.println("下载文件时参数错误");
		}
	}
	/*
	 * 获取研发检测流程word报告名称
	 * wxj
	 */
	public void getYFbaogaoName(){
		PrintWriter out = PubMethod.GetPrintWriter(); 
		JSONObject json1 = new  JSONObject();
		JSONArray jsonarray = new JSONArray();
		JSONArray jsonarrayBd = new JSONArray();
		String fileModeName="";
		String modeName = "研发检测流程报告";
		String fileModeId = this.getRequest().getParameter("fileModeID");
		String mainid = getRequest().getParameter("mainid");
		String flag = "0";
		//查询原始记录路径
		String baogaosql = "select t.BAOGAO from GWM_YANFAJIANCE t  where t.id="+mainid+" and t.baogao is not null";
		List baogaoList= autoFormService.getDatabySql(baogaosql);
		if(null != baogaoList && baogaoList.size()>0){//若存在
			String filePath = baogaoList.get(0).toString();
			String[] filePaths = filePath.split("\\/");  
			if(null != filePaths && !"".equals(filePaths)){
				fileModeName = filePaths[filePaths.length-1];
			}
			
			flag = "1";
		}else{//若不存在
			String sql = "select t.report_name,t.report_path from REPORT_MODE t where t.id='"+fileModeId+"'";
			//查询baogao 
			List fileModeList= autoFormService.getDatabySql(sql);
		    if(null!=fileModeList&&fileModeList.size()>0){
		    	Object[]obj = (Object[])fileModeList.get(0);
		    	modeName = obj[0]!=null?obj[0].toString():"";
				fileModeName = obj[1]!=null?obj[1].toString():"";            //文件名称
		    	//拷贝原始记录单
		    	String tomcatpath=ServletActionContext.getServletContext().getRealPath("/");
		    }
		}
	    //生成报告识别号
	    //年两位
	    Calendar a=Calendar.getInstance();
		String year = String.valueOf(a.get(Calendar.YEAR));
		year = year.substring(year.length()-2, year.length());
		//公司代码
		String sql2 = "select  t.WEITUODANSHIBIENO  from GWM_YANFAJIANCE t where t.id="+mainid;
		List list = autoFormService.getDatabySql(sql2);
		String weituodanshibieno = "";
		if(null!=list&&list.size()>0&&null!=list.get(0)){
			weituodanshibieno = list.get(0).toString();
		}
  		String baogaoshibieno = "SY"+weituodanshibieno.substring(2,weituodanshibieno.length())+"-"+"0001";
  		//后四位数
// 		String sql1 = "select max(substr(t.JIANCEBAOGAOSHIBIENO,length(t.JIANCEBAOGAOSHIBIENO)-3,4)) from GWM_YANFAJIANCE t where  t.JIANCEBAOGAOSHIBIENO like '%"+year+"-%'";
//		List list1 = autoFormService.getDatabySql(sql1);
//		if(null != list1 && list1.size()>0){
//			if(null != list1.get(0) && !"".equals(list1.get(0))){
//				int number = Integer.parseInt(list1.get(0).toString())+1;
//				baogaoshibieno = baogaoshibieno + new DecimalFormat("0000").format(number);
//			}else{
//				baogaoshibieno = baogaoshibieno + "0001";
//			}
//			
//		}
		String sqlupdate = "update GWM_YANFAJIANCE t set t.JIANCEBAOGAOSHIBIENO = '"+baogaoshibieno+"' where  t.id="+mainid;
		autoService.executeSql(sqlupdate);
		String sqlshibieno = "select t.JIANCEBAOGAOSHIBIENO from GWM_YANFAJIANCE t where t.id="+mainid;
		List sqlshibienoList = autoFormService.getDatabySql(sqlshibieno);
		if(null != sqlshibienoList && sqlshibienoList.size()>0){
			json1.put("baogaoshibieno", sqlshibienoList.get(0));
		}
		json1.put("modeName", modeName);
	    json1.put("fileModeName", fileModeName);
	    json1.put("flag", flag);
	    out.print(json1.toString());
	}
	/*
	 * 加载已保存的检测报告----------研发检测流程
	 * wxj
	 */
	public void getYFJCBaogaoDownload() throws Exception{
		String pathname = getRequest().getParameter("path");
		String allpath = getRequest().getParameter("allpath");
		String type = getRequest().getParameter("type");
		String taskid = getRequest().getParameter("taskid");
		String pathUrl = getRequest().getSession().getAttribute("SYS_FILEPATH").toString();
		String path1 = "";
		if(allpath != null && !allpath.equals("")){
			path1 = allpath;
		}else{
			path1 = pathUrl+"/yanfajiancebaogao/"+taskid+"/"+pathname;
		}
		if(!"".equals(path1)){
			File file=new File(path1);//构造要下载的文件	
			if(file.exists()){
				InputStream ins=new FileInputStream(path1);//构造一个读取文件的IO流对象
				BufferedInputStream bins=new BufferedInputStream(ins);//放到缓冲流里面
				OutputStream outs=getResponse().getOutputStream();//获取文件输出IO流
				BufferedOutputStream bouts=new BufferedOutputStream(outs);
				getResponse().setContentType("application/x-download");//设置response内容的类型
				getResponse().setHeader("Content-disposition","attachment;filename="+ URLEncoder.encode(path1, "UTF-8"));//设置头部信息
				int bytesRead = 0;
				byte[] buffer = new byte[8192];
				//开始向网络传输文件流
				while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
					bouts.write(buffer, 0, bytesRead);
				}
				bouts.flush();//这里一定要调用flush()方法
				ins.close();
				bins.close();
				outs.close();
				bouts.close();
			}else{
				System.out.println("下载的文件不存在");
			}
		}else{
			System.out.println("下载文件时参数错误");
		}
	}
	/*
	 * 任务交接
	 * wxj
	 */
	public void renwuyijiao() throws IOException{
		PrintWriter out=getResponse().getWriter();
		try{
			String dailiren = getRequest().getParameter("dailiren");
			String flowtaskinfoid = getRequest().getParameter("flowtaskinfoid");
			FlowTaskInfo flowTaskInfo = codeReviewService.getFlowTaskInfoById(Long.parseLong(flowtaskinfoid));
			flowTaskInfo.setNextUsersId(","+dailiren+",");
			codeReviewService.updateFlowTaskInfo(flowTaskInfo);
			out.print("{\"ajaxResult\":\"success\"}");
		    out.flush();
			out.close();
		}catch (Exception e) {
			e.printStackTrace();
			 out.print("{\"ajaxResult\":\"error\"}");
		}
		
	}
	
	/**
	 * 
	 * 描述：常规检测流程判断原始记录是否有附件
	 * @author wangxd
	 * @date Aug 3, 2015 2:20:12 PM
	 * @return void
	 * @throw
	 */
	public void checkYsjlAnnex(){
		PrintWriter out = PubMethod.GetPrintWriter(); 
	    String id = getRequest().getParameter("ids");
		try {
			String sql = "select t.t_ysjlannex   from gwm_item_sample t  where t.t_ysjlannex is not null and  t.id  = "+id;
			List list = autoFormService.getDatabySql(sql);
			if(null!=list&&list.size()>0&&null!=list.get(0)){
				out.print("{\"ajaxResult\":\"true\"}");
			}
			else{
				out.print("{\"ajaxResult\":\"false\"}");
			}
			
		} catch (Exception e) {
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	/**
	 * 
	 * 描述：常规检测流程 ---删除原始记录附件
	 * @author wangxd
	 * @date Aug 3, 2015 2:35:08 PM
	 * @return void
	 * @throw
	 */
	public void deleteYsjlAnnex(){
		PrintWriter out = PubMethod.GetPrintWriter(); 
	    String id = getRequest().getParameter("ids");
		try {
			String sql = " update gwm_item_sample t set t.t_ysjlannex='',t.t_ysjlannexname ='' where t.id  in ( "+id+")";
			autoFormService.executeSql(sql);
		   out.print("{\"ajaxResult\":\"true\"}");
			
		} catch (Exception e) {
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	/**
	 * 
	 * 描述：常规检测流程 ---》编制报告上传图片
	 * @author wangxd
	 * @date Aug 5, 2015 4:57:43 PM
	 * @return void
	 * @throw
	 */
	public void saveReportImage(){
		PrintWriter out = PubMethod.GetPrintWriter(); 
	    String id = getRequest().getParameter("id");
	    String imageheight = getRequest().getParameter("imageheight");
	    String imagewidth = getRequest().getParameter("imagewidth");
	    String imagesize = imagewidth+","+imageheight;
	    String imagecount = getRequest().getParameter("imagecount");
		try {
			String sql = " insert into gwm_reportimage (id, image_size, image_count) values ("+id+",'"+imagesize+"','"+imagecount+"')";
			autoFormService.executeSql(sql);
		    out.print("{\"ajaxResult\":\"success\"}");
			
		} catch (Exception e) {
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	
	/**
	 * 
	 * 描述：常规检测流程----》编辑报告时查询图片
	 * @author wangxd
	 * @date Aug 6, 2015 2:32:34 PM
	 * @return void
	 * @throw
	 */
	public void getReportImagePath(){
		PrintWriter out = PubMethod.GetPrintWriter(); 
	    String id = getRequest().getParameter("id");
		try {
			String imagesize = "";
			String imagecount = "";
			String imagepath = "";
			int imagewidth = 200;
			int imageheight = 200;
			
			if(!"".equals(id)){
				String sql = "select t.image_size,t.image_count from gwm_reportimage t where t.id = "+id;
				List list = autoFormService.getDatabySql(sql);
				if(null!=list&&list.size()>0&&null!=list.get(0)){
					Object[] obj = (Object[]) list.get(0);
					imagesize = obj[0]!=null?obj[0].toString():"";
					imagecount = obj[1]!=null?obj[1].toString():"";
					String[] arrayimagesize = imagesize.split(",");
					try{
						imagewidth = Integer.parseInt(arrayimagesize[0]);
						imageheight = Integer.parseInt(arrayimagesize[1]);
					}
					catch(Exception exp){
						exp.printStackTrace();
					}
				}
				//查询图片路径
				String ctxDir =getRequest().getSession().getServletContext().getInitParameter("filePath");
				if (!ctxDir.endsWith(String.valueOf(File.separatorChar))) {
					ctxDir = ctxDir + File.separatorChar;
				}
				String sql1 = "select t.file_path,t.file_name from tdm_attachment t where t.file_path is not null and t.code_id = "+id;
				List list1 = autoFormService.getDatabySql(sql1);
				String filenames = "";
				for(int i=0;i<list1.size();i++){
					Object[] objs = (Object[])list1.get(i);
					String filepath = ctxDir+"\\"+objs[0].toString();
					String filename = objs[1]==null?"":objs[1].toString();
					filename = filename.substring(0,filename.indexOf("."));
					filepath = filepath.replace("\\", "&");
					imagepath = imagepath+"@"+filepath;
					filenames = filenames+"@"+filename;
				}
				if (filenames.length()>0){
					filenames = filenames.substring(1);
				}
			    out.print("{\"ajaxResult\":\"true\",\"imagewidth\":\""+imagewidth+"\",\"imageheight\":\""+imageheight+"\",\"imagecount\":\""+imagecount+"\",\"imagepath\":\""+imagepath.substring(1)+"\",\"filenames\":\""+filenames.substring(1)+"\"}");
			}else{
				out.print("{\"ajaxResult\":\"\"}");
			}
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	/**
	 * 
	 *方法描述:查询原始记录的路径是否相同
	 *@author: wangxd
	 *@date: 2014-4-18下午05:10:02
	 *@throws Exception
	 */
	public void checkYsjlPath() throws Exception{
		setContentType();
		PrintWriter out = getResponse().getWriter();
		String ids = getRequest().getParameter("ids");
		String sign = getRequest().getParameter("sign");
		String taskId = getRequest().getParameter("taskId");
		String flag = "";
		String sql = "";
		String values = "";
		try {
			if("0".equals(sign)){       //填写原始记录时判断样品是否接收
				 sql = "select t.id  from gwm_item_sample t left join gwm_sample s on t.t_sampleid = s.id  where s.t_sfguihuan is null and t.id in("+ids+")";
				 List list = autoFormService.getDatabySql(sql);
				 if(null!=list&&list.size()>0){
					 flag = "true";
				 }
			}
			else if("1".equals(sign)){     //原始记录路径是否相同
				 sql = "select distinct t.t_ysjlfilepath from gwm_item_sample t  where t.id in ("+ids+")";
				 List list = autoFormService.getDatabySql(sql);
				 if(null!=list&&list.size()>1){
					 flag = "true";
				 }
			}
			else if("2".equals(sign)){     //判断原始记录是否正在编辑
				 sql = "select t.t_ysjleditor from gwm_item_sample t where t.t_ysjlsfedit=0  and  t.id in ("+ids+")";
				 List list = autoFormService.getDatabySql(sql);
				 if(null!=list&&list.size()>0){
					 flag = "true";
					 values = list.get(0).toString();
				 }
			}
			else if("3".equals(sign)){     //判断列表中的数据是否全部填写原始记录
				 sql = "select t.t_ysjlfilepath from gwm_item_sample t where t.t_ysjlfilepath is null   and  t.id in ("+ids+")";
				 List list = autoFormService.getDatabySql(sql);
				 if(null!=list&&list.size()>0){
					 flag = "true";
				 }
			}
			else if("4".equals(sign)){     //判断列表中的数据是否全部进行电子签名
				 sql = "select t.id from gwm_item_sample t where  t.t_taskinfoid= ("+ids+") and t.t_sfdianziqianm is null  and t.t_sfdelete is null ";
				 List list = autoFormService.getDatabySql(sql);
				 if(null!=list&&list.size()>0){
					 flag = "true";
				 }
			}
			
			else if("5".equals(sign)){     //判断已选的数据的报告路径是否相同
				 sql = "select distinct t.t_bgfilepath from gwm_item_sample t  where t.id in ("+ids+")";
				 List list = autoFormService.getDatabySql(sql);
				 if(null!=list&&list.size()>1){
					 flag = "true";
				 }
			}
			else if("6".equals(sign)){     //判断已选的数据是否选择设备
				 String[] allIds = ids.split(",");
				 for(int i=0;i<allIds.length;i++){
					 String sql1 = "select t.id from gwm_yfjcfuzhushebei t  where  t.taskid = '"+taskId+"' and t.item_sample_id like '%,"+allIds[i]+",%'";
					 List list = autoFormService.getDatabySql(sql1);
					 if(null==list||list.size()==0){
						 flag = "true";
						 break;
					 }
				 }
				
			}
			if("true".equals(flag)){
				out.print("{\"result\":\"true\",\"values\":\""+values+"\"}");
			}else{
				out.print("{\"result\":\"false\"}");
			}
			
		} catch (Exception e) {
			out.print("{\"result\":\"error\"}");
			e.printStackTrace();
		}
	}
	/**
	 * 
	 * 描述：下载文件
	 * @author wangxd
	 * @date Aug 6, 2015 2:46:07 PM
	 * @return void
	 * @throw
	 */
	public void getKnowledgeFileDownload() throws Exception{
		String path = StringUtil.encodingUrl(getRequest().getParameter("allpath"));
		if(!"".equals(path)){
			File file=new File(path);//构造要下载的文件	
			if(file.exists()){
				InputStream ins=new FileInputStream(path);//构造一个读取文件的IO流对象
				BufferedInputStream bins=new BufferedInputStream(ins);//放到缓冲流里面
				OutputStream outs=getResponse().getOutputStream();//获取文件输出IO流
				BufferedOutputStream bouts=new BufferedOutputStream(outs);
				getResponse().setContentType("application/x-download");//设置response内容的类型
				getResponse().setHeader("Content-disposition","attachment;filename="+ URLEncoder.encode(path, "UTF-8"));//设置头部信息
				int bytesRead = 0;
				byte[] buffer = new byte[8192];
				//开始向网络传输文件流
				while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
					bouts.write(buffer, 0, bytesRead);
				}
				bouts.flush();//这里一定要调用flush()方法
				ins.close();
				bins.close();
				outs.close();
				bouts.close();
			}else{
				System.out.println("下载的文件不存在");
			}
		}else{
			System.out.println("下载文件时参数错误");
		}

	}
	
	public void getImageFileDownload() {
		try{
		String path = StringUtil.encodingUrl(getRequest().getParameter("allpath"));
		if(!"".equals(path)){
			File file=new File(path);//构造要下载的文件	
			if(file.exists()){
				String imagewidth = getRequest().getParameter("imagewidth");
				String imageheight = getRequest().getParameter("imageheight");
				ImageHelper.resizeImage(path, path, Integer.parseInt(imageheight), Integer.parseInt(imageheight));
				InputStream ins=new FileInputStream(path);//构造一个读取文件的IO流对象
				BufferedInputStream bins=new BufferedInputStream(ins);//放到缓冲流里面
				OutputStream outs=getResponse().getOutputStream();//获取文件输出IO流
				BufferedOutputStream bouts=new BufferedOutputStream(outs);
				getResponse().setContentType("application/x-download");//设置response内容的类型
				getResponse().setHeader("Content-disposition","attachment;filename="+ URLEncoder.encode(path, "UTF-8"));//设置头部信息
				int bytesRead = 0;
				byte[] buffer = new byte[8192];
				//开始向网络传输文件流
				while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
					bouts.write(buffer, 0, bytesRead);
				}
				bouts.flush();//这里一定要调用flush()方法
				ins.close();
				bins.close();
				outs.close();
				bouts.close();
			}else{
				System.out.println("下载的文件不存在");
			}
		}else{
			System.out.println("下载文件时参数错误");
		}
		}
		catch(Exception exp){
			exp.printStackTrace();
		}

	}
	/**
	 * 
	 * 描述：常规检测流程 --->报告与原始记录发放
	 * @author wangxd
	 * @date Aug 10, 2015 5:42:56 PM
	 * @return void
	 * @throw
	 */
	public void bgAndysjlfafang() throws IOException{
		PrintWriter out = getResponse().getWriter();
		String ids = getRequest().getParameter("ids");
		String taskinfoid = getRequest().getParameter("taskinfoid");
		//同路径的数据
		String idsSql = "select wmsys.wm_concat(t.id) from GWM_ITEM_SAMPLE t where t.T_TASKINFOID="+taskinfoid+" and t.t_bgfilepath in (select distinct tt.t_bgfilepath from GWM_ITEM_SAMPLE tt where tt.id in ("+ids+"))";
		List queryIdsSqlList = autoService.getDatabySql(idsSql);
		String item_sample_ids = "";
		if(null != queryIdsSqlList && queryIdsSqlList.size()>0 && null != queryIdsSqlList.get(0) && !"".equals(queryIdsSqlList.get(0))){
			item_sample_ids = item_sample_ids+","+queryIdsSqlList.get(0).toString();
		}
		try {
			String sql = " update gwm_item_sample   set   t_reportsftj = 0  where id in ("+item_sample_ids+")";
			autoFormService.executeSql(sql);
			out.print("{\"result\":\"true\"}");
		} catch (Exception e) {
			out.print("{\"result\":\"error\"}");
			e.printStackTrace();
		}
	}
	/**
	 * 
	 * 描述：样品接收
	 * @author wangxd
	 * @date Aug 21, 2015 4:08:20 PM
	 * @return void
	 * @throw
	 */
	public void queryGwmSampleManageList(){
		try {
			Map<String, String> filterMap = getPagerMap();
			String shenqingrq = getRequest().getParameter("shenqingrq");
			String endrq = getRequest().getParameter("endrq");
			String weituodanwei = getRequest().getParameter("weituodanwei");
			String shibiehao = getRequest().getParameter("shibiehao");
			String weituoren = getRequest().getParameter("weituoren");
			String flag = getRequest().getParameter("flag");   //0：样品接收  1：样品归还
			String samplestate = getRequest().getParameter("samplestate");   //0：未归还  1：已归还
			// 解决乱码问题
			if (weituodanwei != null && !"".equals(weituodanwei)) {
				weituodanwei = StringUtil.encodingUrl(weituodanwei);
			}
			if (shibiehao != null && !"".equals(shibiehao)) {
				shibiehao = StringUtil.encodingUrl(shibiehao);
			}
			if (weituoren != null && !"".equals(weituoren)) {
				weituoren = StringUtil.encodingUrl(weituoren);
			}
			filterMap.put("flag", flag);
			filterMap.put("shenqingrq", shenqingrq);
			filterMap.put("endrq", endrq);
			filterMap.put("weituodanwei", weituodanwei);
			filterMap.put("shibiehao", shibiehao);
			filterMap.put("weituoren", weituoren);
			filterMap.put("samplestate", samplestate);
			filterMap.put("userId", this.getUserId());
			String[] viewArray = { "ID", "T_WEITUOHAO", "T_TASKNAME", "T_WEITUODANW","USERNAME","T_SHENQINGRQ","T_TELEPHONE","T_TASKID","T_SAMPLESTATE:[{'0':'未归还','1':'已归还'}]"};
			PageResult result = codeReviewService.queryGwmSampleManageList(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");// 定义输出的类型
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");// 定义输出的类型
			PrintWriter out = PubMethod.GetPrintWriter();
			out.print(returnStr);
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 
	 * 描述：样品接收： 样品列表
	 * @author wangxd
	 * @date Aug 21, 2015 5:44:38 PM
	 * @return void
	 * @throw
	 */
	public void querySampleDetailBytaskId(){
		try {
			Map<String, String> filterMap = getPagerMap();
			String flag = getRequest().getParameter("flag");
			String taskId = getRequest().getParameter("taskId");
			String sampleIds = getRequest().getParameter("sampleIds");
		
			filterMap.put("flag", flag);
			filterMap.put("taskId", taskId);
			filterMap.put("sampleIds", sampleIds);
			String[] viewArray = { "ID", "T_SAMPLENAME","T_SAMPLENO","T_JIESHOUNUM","T_PICI","T_MANUFACTURER","T_JIESHOUREN","T_SAMPLECHULI","T_JIESHOUTIME","T_JIESHOUREMARK","T_GUIHUANTIME","T_GUIHUANREN","T_GUIHUANNUM","T_LINGYONGREN","T_GUIHUANREMARK"};
			PageResult result = codeReviewService.querySampleDetailBytaskId(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");// 定义输出的类型
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");// 定义输出的类型
			PrintWriter out = PubMethod.GetPrintWriter();
			out.print(returnStr);
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 
	 * 描述：保存样品接收
	 * @author wangxd
	 * @date Aug 24, 2015 5:41:19 PM
	 * @return void
	 * @throws IOException 
	 * @throw
	 */
	public void savesampleAccept() throws IOException{
		PrintWriter out = getResponse().getWriter();
		String msg = getRequest().getParameter("msg");
		if(!"".equals(msg)){
			msg = StringUtil.encodingUrl(msg);
		}
		try {
			codeReviewService.savesampleAccept(msg);
			out.print("{\"result\":\"true\"}");
			
		} catch (Exception e) {
			out.print("{\"result\":\"error\"}");
			e.printStackTrace();
		}
	}
	/**
	 * 
	 * 描述：样品归还 保存
	 * @author wangxd
	 * @date Aug 25, 2015 6:18:13 PM
	 * @return void
	 * @throw
	 */
	public void saveReturnSample() throws IOException{
		PrintWriter out = getResponse().getWriter();
		String msg = getRequest().getParameter("msg");
		if(!"".equals(msg)){
			msg = StringUtil.encodingUrl(msg);
		}
		try {
			codeReviewService.saveReturnSample(msg);
			out.print("{\"result\":\"true\"}");
			
		} catch (Exception e) {
			out.print("{\"result\":\"error\"}");
			e.printStackTrace();
		}
	}
	
	/**
	 * 
	 * 描述：常规检测流程  调度审核委托单节点 项目分配页面的判断 报告编辑节点是否电子签名
	 * @author wangxd
	 * @date Sep 22, 2015 3:47:07 PM
	 * @return void
	 * @throw
	 */
	public void checkSampleSFFenpei() throws IOException{
		PrintWriter out = getResponse().getWriter();
	  	try {
	  		String taskId = getRequest().getParameter("taskId");
	  		String flag = getRequest().getParameter("flag");    
			String flowtaskinfoid = getRequest().getParameter("flowtaskinfoid");
			String ids = getRequest().getParameter("ids");
	  		String sql = "";
			List list = null;
			// 0:是否所有的样品编号都选择科室领导
			if("0".equals(flag)){
				sql = "select t.id from GWM_SAMPLENOFLOW t   LEFT JOIN GWM_SAMPLE S  ON T.T_SAMPLEID = S.ID where s.T_TASKID = '"+taskId+"' and t.id not in ( select g.t_samplenoid from gwm_item_sample g  where g.t_taskid='"+taskId+"') ";
				list = autoFormService.getDatabySql(sql);
			}
			
			// 1：试验任务接收节点： 有流程分支不允许退回
			else if("1".equals(flag)){
				sql = "select t.id from flow_task_info t where  t.flow_task_id="+taskId+" and t.id <>"+flowtaskinfoid;
				list = autoFormService.getDatabySql(sql);
			}
			
			//2：报告编辑节点是否电子签名  
			else if("2".equals(flag)){
				sql = "select t.id from gwm_item_sample t where t.id in ("+ids+") and  t.t_reportsfqianming is null ";
				list = autoFormService.getDatabySql(sql);
			}
			
			//3:报告审核节点 报告是否有电子签名  
			else if("3".equals(flag)){
				sql = "select t.id from gwm_item_sample t where t_taskinfoid = "+flowtaskinfoid+" and  t.t_reportsfqianming is null ";
				list = autoFormService.getDatabySql(sql);
			}
			
			//4：调度节点检测项目是否分配检测标准
			else if("4".equals(flag)){
				sql = "select t.id from gwm_item_flow t  where t.t_taskid= "+taskId+" and t.t_itemid in ("+ids+")  and t.t_jiancebiaozhun is  null ";
				list = autoFormService.getDatabySql(sql);
			}
			
			if(null!=list&&list.size()>0){
				out.print("{\"ajaxResult\":\"true\"}");
			}else{
				out.print("{\"ajaxResult\":\"false\"}");
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	/**
	 * 
	 * 描述：原始记录页面关闭后 修改原始记录的状态为1
	 * @author wangxd
	 * @date Sep 22, 2015 5:50:34 PM
	 * @return void
	 * @throw
	 */
	public void updateYsjlState() throws IOException{
		PrintWriter out = getResponse().getWriter();
	  	try {
	  		String ids = getRequest().getParameter("ids");
	  	    //修改gwm_item_sample 表中T_YSJLSFEDIT【原始记录是否编辑】的值为1
			String updateSql = "update  gwm_item_sample t set t.t_ysjlsfedit=1,t.t_ysjleditor='' where t.id in ("+ids+")";
			autoFormService.executeBySql(updateSql);
			
			out.print("{\"ajaxResult\":\"true\"}");
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	public static void copyFile(File sourceFile, File targetFile) throws IOException {
        BufferedInputStream inBuff = null;
        BufferedOutputStream outBuff = null;
        try {
            // 新建文件输入流并对它进行缓冲
            inBuff = new BufferedInputStream(new FileInputStream(sourceFile));

            // 新建文件输出流并对它进行缓冲
            outBuff = new BufferedOutputStream(new FileOutputStream(targetFile));

            // 缓冲数组
            byte[] b = new byte[1024 * 5];
            int len;
            while ((len = inBuff.read(b)) != -1) {
                outBuff.write(b, 0, len);
            }
            // 刷新此缓冲的输出流
            outBuff.flush();
        } finally {
            // 关闭流
            if (inBuff != null)
                inBuff.close();
            if (outBuff != null)
                outBuff.close();
        }
    }
	
	public void delComments(String taskid){
		String strSql = "select distinct T_YSJLFILEPATH FROM GWM_ITEM_SAMPLE T   WHERE  T.T_TASKID ='"+taskid+"' and t.t_ysjlfilepath is not null";
		List lists = autoFormService.findAllBySql(strSql);
		for(int i=0;i<lists.size();i++){
			ExcelTool et = new ExcelTool(lists.get(i).toString());
			et.delComments();
			et.Save();
		}
	}

	/**
	 * 生成其他打印单
	 * @throws Exception
	 */
	public void getOtherfilename() throws Exception{
		PrintWriter out = PubMethod.GetPrintWriter(); 
		JSONObject json1 = new  JSONObject();
		JSONObject json2 = new  JSONObject();
		JSONArray jsonarray = new JSONArray();
		JSONArray jsonarraySample = new JSONArray();
		JSONArray jsonarrayItem = new JSONArray();
		JSONArray jsonarrayOtherItem = new JSONArray();
		
		List itemList = null;
		
		 String[] sampleBiaoqian= null;     //样品标签
		
		String taskid = this.getRequest().getParameter("taskid");
		String type = this.getRequest().getParameter("type");//type为1则是打开配置的模版，否则则是查看保存过的模版
		String chooseFormId = this.getRequest().getParameter("chooseFormId");//被关联的表单id
		FlowTask task = codeReviewService.getFlowTaskById(Long.parseLong(taskid));
	    String xzgyId = this.getRequest().getParameter("xzgyId");
	    //文档路径
	    String filepath = getRequest().getParameter("filepath");
	    //配置的模版id
	    String printModeId = getRequest().getParameter("printModeId");
    	//拷贝原始记录单
    	String tomcatpath=ServletActionContext.getServletContext().getRealPath("/");
		//String path=ServletActionContext.getServletContext().getRealPath("/");
    	//样品袋的项目组个数
    	List sydList = null;
    	//类型
		String flag = getRequest().getParameter("flag");    //wtd：委托单  bsk:样品标识卡
		String mainid = getRequest().getParameter("mainid");
		

		//查询合格证对应的TDM_CENTIFICATEMODE_ITEM,流程中的
		itemList = codeReviewService.queryTdmPrintreportmodeItem(printModeId, "1");
	
		for(int i =0; i<itemList.size();i++){
			JSONObject json = new JSONObject();
			Object[] objs = (Object[])itemList.get(i);
			String labelName = "";
			String labelValue = "";
			boolean sign = true;
			
			if("bsk".equals(flag)&&"GWM_SAMPLE".equals(objs[2])){
				sign = false;
			}
			if(sign){
				//根据配置标签的关系 去查询数据库里对应的值
				String bqValueSql  = "select "+objs[1]+" from "+objs[2]+" t where t.id = "+task.getMainId();
				List objList = codeReviewService.queryListBySql(bqValueSql);
				Object labelObj = null;
				if(null!=objList&&objList.size()>0&&null!=objList.get(0)){
					labelObj = objList.get(0);
				}
				
				//判断是否是选择人员
				String personSql = "select t.id from auto_forms_field t where t.page_display_type = '11' "+
								   " and t.field_name = '"+objs[1]+"' "+
								   " and t.forms_id in (select t.id from auto_forms_new t where t.form_en_name = '"+objs[2]+"')";
				List personList =  codeReviewService.queryListBySql(personSql);
				//判断是否是选择部门
				String deptSql = "";
				
				//判断标签是否是外键 如果是外键查询对应的名称
				String sql1 = "select distinct tt.foreign_dis_cloumn,tt.foreign_table_name  from auto_forms_field tt " +
						      "where tt.field_name = '"+objs[1]+"'  and tt.foreign_table_name is not null and tt.foreign_dis_cloumn is not null " +
						      "and tt.forms_id in (select t.id  from auto_forms_new t where t.form_en_name = '"+objs[2]+"')";
				List list1 =  codeReviewService.queryListBySql(sql1);
				if(list1!=null&&list1.size()>0&&null!=labelObj){//判断外键
					Object[] obj1 = (Object[])list1.get(0);
					if(null!=list1.get(0)){
						String sql2 = "select "+obj1[0]+" from "+obj1[1]+" t where t.id = "+labelObj.toString();
						List list2 = codeReviewService.queryListBySql(sql2);
						if(null!=list2&&list2.size()>0&&null!=list2.get(0)){
							labelValue = list2.get(0)!=null?list2.get(0).toString():"";
						}
					}
				}else if(personList!=null&&personList.size()>0&&null!=labelObj){//判断人员
					if(null!=personList.get(0)){
						String sql3 = "select username from sys_users t where t.userid = "+labelObj.toString();
						List list3 = codeReviewService.queryListBySql(sql3);
						if(null!=list3&&list3.size()>0&&null!=list3.get(0)){
							Object obj3 = list3.get(0);
							labelValue = obj3!=null?obj3.toString():"";
						}
					}
				}
				//生成委托单
				else if("wtd".equals(flag)&&("T_WEITUOREN".equals(objs[1])||"T_PIZHUNREN".equals(objs[1])||"T_JIESHOUDAIBIAO".equals(objs[1]))){
					String sql3 = "select username from sys_users t where t.userid = "+labelObj.toString();
					List list3 = codeReviewService.queryListBySql(sql3);
					if(null!=list3&&list3.size()>0&&null!=list3.get(0)){
						Object obj3 = list3.get(0);
						labelValue = obj3!=null?obj3.toString():"";
					}
				}
				else{
					labelValue = labelObj!=null?labelObj.toString():"";
				}
				json.put("label", objs[0].toString());
				json.put("labelValue", labelValue);
				jsonarray.add(json);
			}
			
		}
		
	  
	    //生成委托单按钮：查询样品信息和检测项目信息
	    if("wtd".equals(flag)){
	    	List dongtaiBiaoqian = codeReviewService.queryPrintbiaoqNameById(Long.parseLong(printModeId), "3");    //动态行列标签
			if(null!=dongtaiBiaoqian&&dongtaiBiaoqian.size()>0){
				sampleBiaoqian = new String[dongtaiBiaoqian.size()+1];
				for(int i=0;i<dongtaiBiaoqian.size();i++){
					JSONObject json = new JSONObject();
					Object[] objs = (Object[])dongtaiBiaoqian.get(i);
					if(null!=objs[1]&&"GWM_SAMPLE".equals(objs[1].toString())){
						sampleBiaoqian[i]=objs[0].toString();
					}
				}
				
			}
			//查询样品和检测项目
			jsonarraySample = getPrintModeDongtaiHangData(printModeId,taskid);
			//查询检测项目
			jsonarrayItem = getPrintModeItem(taskid,"0");
			//其他检测项目
			//jsonarrayOtherItem = getPrintModeItem(taskid,"1");
			
	    }
	    //样品标识卡
	    else if("bsk".equals(flag)){
			//查询样品的值
			String querySampleSql = "select t.id,t_samplename,t_sampleno,t_samplechuli from gwm_sample t where t.t_taskid = "+taskid +" order by t.id asc ";
			List sampleList = autoFormService.getDatabySql(querySampleSql);
			if(null!=sampleList&&sampleList.size()>0){
				for(int j=0;j<sampleList.size();j++){
					JSONObject json = new JSONObject();
					Object[] obj = (Object[])sampleList.get(j);
					json.put("样品名称", obj[1]!=null?obj[1].toString():"");
					json.put("样品编号", obj[2]!=null?obj[2].toString():"");
					json.put("样品处理", obj[3]!=null?obj[3].toString():"");
					jsonarraySample.add(json);
				}
			}
//	    	String fieldName ="";
//	    	String sql ="select distinct t.field_cname,t.field_ename from tdm_printreportmode_item t where t.file_mode_id = "+printModeId+" and t.form_ename='GWM_SAMPLE' and t.bq_type = 1 and t.field_cname is not null and t.field_ename is not null ";			
//			List list = autoFormService.getDatabySql(sql);
//			if(null!=list&&list.size()>0&&null!=list.get(0)){
//				sampleBiaoqian = new String[list.size()];
//				for(int i=0;i<list.size();i++){
//					Object[] obj = (Object[])list.get(i);
//					sampleBiaoqian[i] = obj[0].toString();
//					fieldName +=","+obj[1].toString();
//				}
//				//查询样品的值
//				String querySampleSql = "select t.id "+fieldName +" from gwm_sample t where t.t_taskid = "+taskid +" order by t.id asc ";
//				List sampleList = autoFormService.getDatabySql(querySampleSql);
//				if(null!=sampleList&&sampleList.size()>0){
//					for(int j=0;j<sampleList.size();j++){
//						JSONObject json = new JSONObject();
//						Object[] obj = (Object[])sampleList.get(j);
//						String  sampleId = obj[0].toString();
//						json.put("sampleId",sampleId);
//						for(int m=1;m<obj.length;m++){
//							String biaoqian =sampleBiaoqian[m-1];  //标签名称
//							String value = obj[m].toString();    //标签对应的值
//							json.put(biaoqian, value);
//						}
//						jsonarraySample.add(json);
//					}
//				}
//			}
	    }
	    json1.put("flag", flag);
	    json1.put("sampleBiaoqian", sampleBiaoqian);
	    json1.put("sydList", sydList);
	    json1.put("jsonarraySample", jsonarraySample);
	    json1.put("jsonarrayItem", jsonarrayItem);
	    json1.put("jsonarrayOtherItem", jsonarrayOtherItem);
	    json1.put("centificateModeName", filepath);
	    json1.put("jsonarray", jsonarray);//表单中取的值
	    json1.put("chooseFormId", chooseFormId);//关联表单id
	    System.out.println("------------"+json1.toString());
	    out.print(json1.toString());
	}
	
	/**
	 * 
	 * 描述：动态行样品信息
	 * @author wangxd
	 * @date Sep 25, 2015 1:44:21 PM
	 * @return JSONArray
	 * @throw
	 */
	private JSONArray getPrintModeItem(String taskId,String flag){
		JSONArray jsonarray = new JSONArray();
		String sql = " select distinct t.t_itemname,t.t_jiancebiaozhun from gwm_item_flow T where   t.T_TASKID = "+taskId+" and t.t_itemtype ="+flag+" order by t.t_itemname asc ";
		List list = autoService.getDatabySql(sql);
		if(null!=list&&list.size()>0){
			for(int i=0;i<list.size();i++){
				JSONObject json = new JSONObject();
				Object[] obj = (Object[])list.get(i);
				
				String itemname = obj[0]!=null?obj[0].toString():"";
				String biaozhun = obj[1]!=null?obj[1].toString():"";
				if("0".equals(flag)){
					json.put("itemname", itemname);
					json.put("biaozhun", biaozhun);
				}
				else if("1".equals(flag)){
					json.put("otheritem", itemname);
					json.put("otherbiaozhun", biaozhun);
				}
				jsonarray.add(json);
			}
		}
		return jsonarray;
		
	}
		/**
		 * 
		 * 描述：动态行样品信息
		 * @author wangxd
		 * @date Sep 25, 2015 1:44:21 PM
		 * @return JSONArray
		 * @throw
		 */
		private JSONArray getPrintModeDongtaiHangData(String filemodeId,String taskid){
		JSONArray jsonarray = new JSONArray();
		String dongtaiBiaoqianName = "";
		String sampleFiledNames ="";     
    	String name1 = "";  
    	String orgId = "";
    	List dongtaiBiaoqian = codeReviewService.queryPrintbiaoqNameById(Long.parseLong(filemodeId), "3");    //动态行列标签
	    if(null!=dongtaiBiaoqian&&dongtaiBiaoqian.size()>0){
	    	for(int i=0;i<dongtaiBiaoqian.size();i++){
	    		JSONObject json = new JSONObject();
				Object[] objs = (Object[])dongtaiBiaoqian.get(i);
				try{
				   String  checkFieldNameexit = "select "+objs[2]+ " from "+objs[1];
				   if(null!=objs[1]&&"GWM_SAMPLE".equals(objs[1].toString())){
					    name1 ="t.";
					    
					}
				    if(!"".equals(name1)){
				    	
				    	if("T_YINGYONGCHEXING".equals(objs[2])){  //样品中的应用车型
				    		sampleFiledNames +=",b.t_chexingname";
					    }else{
				    	   sampleFiledNames +=","+name1+objs[2];
					    }
				    	dongtaiBiaoqianName +=","+objs[0];
				    }
				}catch(Exception e){
				}
	    	}
	    }
	    if(!"".equals(dongtaiBiaoqianName)){
	    	dongtaiBiaoqianName = dongtaiBiaoqianName.substring(1);
	        //查询流程中动态行的数据
	 	   String flowItemSql = "select  t.id "+sampleFiledNames+" from  gwm_sample t left join gwm_applicationmode b on t.t_yingyongchexing = b.id where t.t_taskid= "+taskid;
	 	  
	 	   List flowItemList = codeReviewService.queryListBySql(flowItemSql);
	 	   if(null!=flowItemList&&flowItemList.size()>0){
	 		   String[] biaoqian = null;
	 		   if(!"".equals(sampleFiledNames)){
	 			  biaoqian = dongtaiBiaoqianName.split(",");
	 		   }
	 		   for(int j=0;j<flowItemList.size();j++){
	 			   Object[] obj = (Object[])flowItemList.get(j);
	 				if(obj[0]!=null){
	 					JSONObject json = new JSONObject();
	 					json.put("id", obj[0]!=null?obj[0].toString():"");
	 					 
	 					//获得对应标签的值
	 					for(int f=0;f<biaoqian.length;f++){
	 						String value =  obj[f+1]!=null?obj[f+1].toString():"";
	 						json.put(biaoqian[f], value);
	 					}
	 					jsonarray.add(json);
	 				}
	 		   }
	 	   }
	    }
	
	   return jsonarray;
	}
   /**
    * 
    * 描述：常规检测流程---》填写原始记录节点选择报告编制人
    * @author wangxd
    * @date Sep 28, 2015 2:46:19 PM
    * @return void
    * @throw
    */
    public void queryTestUserByTaskInfoId() throws IOException{
			PrintWriter out = getResponse().getWriter();
		  	try {
		  		String taskId = getRequest().getParameter("taskId");
		  		String flowtaskinfoid = getRequest().getParameter("flowtaskinfoid");
		  		
				String sql = "select wmsys.wm_concat(distinct t.t_jianceyuanid) from gwm_item_sample t where t.t_taskid="+taskId+" and  t.t_taskinfoid="+flowtaskinfoid;
				List list = autoFormService.getDatabySql(sql);
				if(null!=list&&list.size()>0&&null!=list.get(0)){
					out.print("{\"ajaxResult\":\""+list.get(0)+"\"}");
				}else{
					out.print("{\"ajaxResult\":\"false\"}");
				}
				
			} catch (Exception e) {
				e.printStackTrace();
				out.print("{\"ajaxResult\":\"error\"}");
			}
			
	}
    
    public void inportperson(){
//    	ExcelTool et = new ExcelTool("d:\\人力资源报表.xls");
//    	//907
//    	for(int i=537;i<=907;i++){
//    		String bianhao = et.GetCells(1, i, 1).toLowerCase();
//    		String xingming = et.GetCells(1, i, 2);
//    		String bumen = et.GetCells(1, i, 3);
//    		String bumenid = "";
//    		String strSql ="select t.org_id from sys_organization t where t.org_no='"+bumen+"'";
//    		List lists = autoFormService.getDatabySql(strSql);
//    		if (lists.size()>0){
//    			bumenid = lists.get(0)==null?"":lists.get(0).toString();
//    		}
//    		strSql = "insert into sys_users(userid,org_id,loginname,psw," +
//    				"active,username,security_class,del_flag,lock_flag)" +
//    				" values(seq_users.nextval,'"+bumenid+"','"+bianhao+"','c4ca4238a0b923820dcc509a6f75849b'," +
//    				"'1','"+xingming+"','1','1','0')";
//    		autoFormService.executeBySql(strSql);
//    	} 
//    	et.Save();
    }
    /*
     * 校验是否有报告----研发检测项目
     * wxj
     */
    public void checkYanFaBaogao() throws IOException{
    	PrintWriter out = getResponse().getWriter();
	  	try {
	  		String mainid = getRequest().getParameter("mainid");
	  		
			String sql = "select t.BAOGAO from GWM_YANFAJIANCE t where t.id="+mainid;
			List list = autoFormService.getDatabySql(sql);
			if(null!=list&&list.size()>0&&null!=list.get(0)){
				out.print("{\"ajaxResult\":\"true\"}");
			}else{
				out.print("{\"ajaxResult\":\"false\"}");
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
		}
    }
	public LogService getLogService() {
		return logService;
	}

	public void setLogService(LogService logService) {
		this.logService = logService;
	}

	public ICodeReviewService getCodeReviewService() {
		return codeReviewService;
	}

	public void setCodeReviewService(ICodeReviewService codeReviewService) {
		this.codeReviewService = codeReviewService;
	}

	public IAutoService getAutoService() {
		return autoService;
	}

	public void setAutoService(IAutoService autoService) {
		this.autoService = autoService;
	}

	public IAutoFormService getAutoFormService() {
		return autoFormService;
	}

	public void setAutoFormService(IAutoFormService autoFormService) {
		this.autoFormService = autoFormService;
	}

	public Flowtype getFlowtype() {
		return flowtype;
	}

	public void setFlowtype(Flowtype flowtype) {
		this.flowtype = flowtype;
	}

	public Users getUser() {
		return user;
	}

	public void setUser(Users user) {
		this.user = user;
	}

	public String getIsshow() {
		return isshow;
	}

	public void setIsshow(String isshow) {
		this.isshow = isshow;
	}

	public List getUploadfile() {
		return uploadfile;
	}

	public void setUploadfile(List uploadfile) {
		this.uploadfile = uploadfile;
	}

	public List getUploadfileContentType() {
		return uploadfileContentType;
	}

	public void setUploadfileContentType(List uploadfileContentType) {
		this.uploadfileContentType = uploadfileContentType;
	}

	public List getUploadfileFileName() {
		return uploadfileFileName;
	}

	public void setUploadfileFileName(List uploadfileFileName) {
		this.uploadfileFileName = uploadfileFileName;
	}

	public EquipmentService getEpService() {
		return epService;
	}

	public void setEpService(EquipmentService epService) {
		this.epService = epService;
	}
}
